PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹21. 寺嘘媆誕嬉誕

21.2. 庖严镖櫇毕

PostgreSQL 脘崘傖劇䓉庖严镖庻嗘桺橸懫套 ISO-8859 係彖启 EUC(欷匘 Unix 䚡乕)㔕UTF-8 㔕Mule 啘鍙䚡乕㔗欔橬庖严镖鄘埇傖婘橉媇単婪锟滯婄嘪䫘㔗套悩嘹嘪䫘庖準躻噽垄昄扞溊䔇欷匘庘昄闼幽垄埡喿庯傡傸滇劥溼䇞婄幥喍庖傼乕㔗䚺䩕䔇庖严镖滇婘嘪䫘 initdb 彺哋寡昄扞康镖䆴䔇施唍锬拷䔇㔗婘嘹录傺昄扞康䔇施唍滇埇傖襖䕡認婻䚺䩕䔇㔗啹溴嘹埇傖橬崔婻昄扞康懟婻鄘橬婉劯䔇庖严镖㔗

21.2.1. 櫇毕䔇庖严镖䚡乕

臘21-1 滆䴺庖埇傖䫘婘橉媇単䔇庖严镖㔗

臘21-1. PostgreSQL 橉媇単庖严镖

劉庖柟誄臺蘔橉媇䆇?庖誗/庖严彆劉
BIG5崓庫乕乕嘷婺桺No1-2WIN950, Windows950
EUC_CN欷匘UNIX傼乕-CN䞔嘷婺桺Yes1-3 
EUC_JP欷匘UNIX傼乕-JP斖桺Yes1-3 
EUC_KR欷匘UNIX傼乕-KR阷桺Yes1-3 
EUC_TW欷匘UNIX傼乕-TW乕嘷婺桺埄湆Yes1-3 
GB18030啘湺乕婺桺No1-2 
GBK欷匘啘湺乕䞔嘷婺桺No1-2WIN936, Windows936
ISO_8859_5ISO 8859-5, ECMA 113括婕/薪麯儫臺Yes1 
ISO_8859_6ISO 8859-6, ECMA 114括婕/黪括嚇臺Yes1 
ISO_8859_7ISO 8859-7, ECMA 118括婕/婯虪臺Yes1 
ISO_8859_8ISO 8859-8, ECMA 121括婕/婯嚇诌臺Yes1 
JOHABJOHAB阷臺Yes1-3 
KOI8KOI8-R(U)薪麯儫臺Yes1KOI8R
LATIN1ISO 8859-1, ECMA 94薪渓臺Yes1ISO88591
LATIN2ISO 8859-2, ECMA 94婺渓臺Yes1ISO88592
LATIN3ISO 8859-3, ECMA 94剖渓臺Yes1ISO88593
LATIN4ISO 8859-4, ECMA 94寖渓臺Yes1ISO88594
LATIN5ISO 8859-9, ECMA 128婘蔿噽臺Yes1ISO88599
LATIN6ISO 8859-10, ECMA 144斖蔿敚臺Yes1ISO885910
LATIN7ISO 8859-13濵䘖䔇教臺Yes1ISO885913
LATIN8ISO 8859-14庇儫䬹臺Yes1ISO885914
LATIN9ISO 8859-15婥橬渓显臺係启臺脄䔇 LATIN1Yes1ISO885915
LATIN10ISO 8859-16, ASRO SR 14111䘖鷸儚应臺Yes1ISO885916
MULE_INTERNALMule 啘鍙䚡乕崔臺䓉 EmacsYes1-4 
SJISShift JIS斖臺No1-2Mskanji, ShiftJIS, WIN932, Windows932
SQL_ASCII橻弄滯(蓕桺橸)傂懟Yes1 
UHC䂘婔阷臺䚡乕阷臺No1-2WIN949, Windows949
UTF8Unicode, 8-bit噘鄘Yes1-4Unicode
WIN866Windows CP866薪麯儫臺Yes1ALT
WIN874Windows CP874濄啘臺Yes1 
WIN1250Windows CP1250婺渓臺Yes1 
WIN1251Windows CP1251薪麯儫臺Yes1WIN
WIN1252Windows CP1252薪渓臺Yes1 
WIN1253Windows CP1253婯虪臺Yes1 
WIN1254Windows CP1254婘蔿噽臺Yes1 
WIN1255Windows CP1255婯嚇準臺Yes1 
WIN1256Windows CP1256黪括嚇臺Yes1 
WIN1257Windows CP1257濵䘖䔇臺Yes1 
WIN1258Windows CP1258轪剖臺Yes1ABC, TCVN, TCVN5712, VSCII

幽麂欔橬API鄘櫇毕婪麵彖庺䔇䚡乕㔗懫套PostgreSQL JDBC鷌媘儌婉櫇毕 MULE_INTERNAL, LATIN6, LATIN8, LATIN10

SQL_ASCII 螆䘞婯噽垄螆䘞臘䯄冖䕩嘷婉劯㔗套悩橉媇単庖严镖滇 SQL_ASCII 橉媇単檪庖誗唚 0-127 䔇昄唚湹扞 ASCII 湺庖蓼悊蔯庖誗唚 128-255 䔇彍嘷嘩橻蓼悊䔇庖严㔗套悩螆䘞婺 SQL_ASCII 儌婉嚔橬䚡乕蘸扵㔗啹溴認婻螆䘞嘺橸婉䫘準弄滯欔嘪䫘䔇䚡乕啹婺認婻弄滯嚔媘䘖䚡乕㔗婘崓崔昄愙喕婋套悩嘹嘪䫘庖傂嘘麂 ASCII 昄扞闼幽嘪䫘 SQL_ASCII 螆䘞鄘滇婉滯捺䔇啹婺 PostgreSQL 嚔方濘婞媷嘹蘸扵潡蔙湇黯麂 ASCII 庖严㔗

21.2.2. 螆䘞庖严镖

initdb 婺婔婻 PostgreSQL 镖䆴垔幬䚺䩕䔇庖严镖懫套

initdb -E EUC_JP

檪䚺䩕庖严镖螆䘞婺 EUC_JP(䫘庯斖桺䔇欷匘 Unix 䚡乕)㔗套悩嘹塩渵䫘阪锬釹弄滯䔇臺埇傖䫘 --encoding 傼敪 -E 锬釹㔗套悩澇橬䂍庺 -E--encoding 锬釹initdb 儖嘺庯彽垔䔇寺嘘潡蔙䚺䩕寺嘘臘商彴桺劽锗䔇䚡乕㔗

嘹埇傖录傺婔婻橬五婉劯䚡乕䔇昄扞康

createdb -E EUC_KR korean

儖录傺婔婻嘪䫘 EUC_KR 庖严镖䔇劉庖埆 korean 䔇昄扞康㔗埥崡婔䓉垂䯄桹濘滇嘪䫘 SQL 变傴

CREATE DATABASE korean WITH ENCODING 'EUC_KR';

昄扞康䔇䚡乕滇庻嗘婘 pg_database 係䂘臘婺䔇㔗嘹埇傖䫘 psql-l 锬釹潡 \l 变傴彖庺認底䚡乕㔗

$ psql -l
            List of databases
   Database    |  Owner  |   Encoding    
---------------+---------+---------------
 euc_cn        | t-ishii | EUC_CN
 euc_jp        | t-ishii | EUC_JP
 euc_kr        | t-ishii | EUC_KR
 euc_tw        | t-ishii | EUC_TW
 mule_internal | t-ishii | MULE_INTERNAL
 postgres      | t-ishii | EUC_JP
 regression    | t-ishii | SQL_ASCII
 template1     | t-ishii | EUC_JP
 test          | t-ishii | EUC_JP
 utf8          | t-ishii | UTF8
(9 rows)

㔊麉襕㔏荘䇽嘹埇傖䂍婔婻昄扞康弄滯嘹驔襕䔇傂嘘䚡乕嘖锬拷婔婻婯嘹锬拷䔇寺嘘婉婔躘䔇䚡乕誻滇婉奖䔇啔濘㔗LC_COLLATELC_CTYPE 螆䘞攖䴺婔婻䬹垔䔇䚡乕婯寺嘘䕩噿䔇淉嘩(懫套毐废)婘婉噚垹䔇䚡乕麯冽橬埇脘库䫘髍臇䔇蓼悊㔗

啹婺認底寺嘘螆䘞鄘滇䫌 initdb 喂䂷䔇欔傖婘婉劯䔇昄扞康麯嘪䫘婉劯䔇䚡乕敘崔滇䊖螺蔯婉滇䯄垂㔗認底橺彽冽橬埇脘婘儖準䬽橸䔇 PostgreSQL 冖彄櫹誕㔗

婔婻垬噘嘪䫘崔䓉䚡乕䔇桹濘滇婘 initdb 䔇施唍檪寺嘘螆䘞婺 CPOSIX 認湙儌噿閺庖傂嘘垂鍙䔇寺嘘星懘攓㔗

21.2.3. 橉媇単启垵潙䆇幋閘䔇躻媘庖严镖蘸扵

PostgreSQL 櫇毕婘橉媇単启嬉䆇幋閘䔇躻媘䚡乕蘸扵㔗蘸扵媇敇婘係䂘臘 pg_conversion 婺庻嗘㔗PostgreSQL 婥五婔底鵇垔幬䔇蘸扵㔗垄傸婘臘21-2婺彖庺㔗嘹埇傖嘪䫘 SQL 变傴 CREATE CONVERSION 录傺婔婻桄䔇蘸扵㔗

臘21-2. 垵潙/橉媇単庖严镖蘸扵

橉媇単庖严镖埇䫘垵潙䆇庖严镖
BIG5婉櫇毕啔橉媇単䆇䚡乕
EUC_CNEUC_CN, MULE_INTERNAL, UTF8
EUC_JPEUC_JP, MULE_INTERNAL, SJIS, UTF8
EUC_KREUC_KR, MULE_INTERNAL, UTF8
EUC_TWEUC_TW, BIG5, MULE_INTERNAL, UTF8
GB18030婉櫇毕啔橉媇単䆇䚡乕
GBK婉櫇毕啔橉媇単䆇䚡乕
ISO_8859_5ISO_8859_5, KOI8, MULE_INTERNAL, UTF8, WIN866, WIN1251
ISO_8859_6ISO_8859_6, UTF8
ISO_8859_7ISO_8859_7, UTF8
ISO_8859_8ISO_8859_8, UTF8
JOHABJOHAB, UTF8
KOI8KOI8, ISO_8859_5, MULE_INTERNAL, UTF8, WIN866, WIN1251
LATIN1LATIN1, MULE_INTERNAL, UTF8
LATIN2LATIN2, MULE_INTERNAL, UTF8, WIN1250
LATIN3LATIN3, MULE_INTERNAL, UTF8
LATIN4LATIN4, MULE_INTERNAL, UTF8
LATIN5LATIN5, UTF8
LATIN6LATIN6, UTF8
LATIN7LATIN7, UTF8
LATIN8LATIN8, UTF8
LATIN9LATIN9, UTF8
LATIN10LATIN10, UTF8
MULE_INTERNALMULE_INTERNAL, BIG5, EUC_CN, EUC_JP, EUC_KR, EUC_TW, ISO_8859_5, KOI8, LATIN1 to LATIN4, SJIS, WIN866, WIN1250, WIN1251
SJIS婉櫇毕啔橉媇単䆇䚡乕
SQL_ASCII傂懟(婉嚔埏䫘䚡乕蘸扵)
UHC婉櫇毕啔橉媇単䆇䚡乕
UTF8欔橬櫇毕䔇䚡乕
WIN866WIN866, ISO_8859_5, KOI8, MULE_INTERNAL, UTF8, WIN1251
WIN874WIN874, UTF8
WIN1250WIN1250, LATIN2, MULE_INTERNAL, UTF8
WIN1251WIN1251, ISO_8859_5, KOI8, MULE_INTERNAL, UTF8, WIN866
WIN1252WIN1252, UTF8
WIN1253WIN1253, UTF8
WIN1254WIN1254, UTF8
WIN1255WIN1255, UTF8
WIN1256WIN1256, UTF8
WIN1257WIN1257, UTF8
WIN1258WIN1258, UTF8

襕愿欷嚔躻媘庖严镖蘸扵媘脘嘹媙釂只臬 PostgreSQL 嘹愿婘垵潙䆇嘪䫘䔇庖严镖(䚡乕)㔗嘹埇傖䫘喘庹䓉桹濘垂䯄認婻䕞䔇㔗

啺套方濘誕臯䬹垔䔇庖严蘸扵懫套嘹锬䔇橉媇単䚡乕滇 EUC_JP 蔯垵潙䆇滇 LATIN1 闼幽橬底斖桺庖严婉脘蘸扵潊 LATIN1 㔗認施儖檖只髍臇㔗

套悩垵潙䆇庖严镖垔幬潊庖 SQL_ASCII 闼幽䚡乕蘸扵嚔赆噿閺婉䞇橉媇単䔇庖严镖滇傔幽鄘婔湙㔗启橉媇単婔湙鍴麂嘹䔇噖嘩䯇嵄噘鄘滇 ASCII 昄扞劥彍嘪䫘 SQL_ASCII 滇婉滯捺䔇㔗

21.2.4. 誕婔準黙臂

婋麵滇庥幹劇䓉䌂傋䔇䚡乕係䂘䔇喘婄桹㔗

http://www.i18ngurus.com/docs/984813247.html

婔昘喖橬噿庖严镖䚡乕傖埪傼乕釕䔇桺懼㔗

ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/cjk.inf

臥䂖婄蓼麪庖丸3.2誗庺䯄䔇 EUC_JP, EUC_CN, EUC_KR, EUC_TW 䚡乕㔗

http://www.unicode.org/

Unicode 䔇婂釕㔗

RFC 2044

UTF-8 䔇垔幬㔗


劯锔饡釕嬉誕
寺嘘櫇毕婪婔亓斖婩昄扞康䂘檴噖嘩