]> granicus.if.org Git - postgresql/blob - doc/README.mb
I really hope that I haven't missed anything in this one...
[postgresql] / doc / README.mb
1 postgresql 6.4 multi-byte (MB) support README     Jul 22 1998
2
3                                                 Tatsuo Ishii
4                                                 t-ishii@sra.co.jp
5                   http://www.sra.co.jp/people/t-ishii/PostgreSQL/
6
7 0. Introduction
8
9 The MB support is intended for allowing PostgreSQL to handle
10 multi-byte character sets such as EUC(Extended Unix Code), Unicode and
11 Mule internal code. With the MB enabled you can use multi-byte
12 character sets in regexp ,LIKE and some functions. The encoding system
13 chosen is determined when initializing your PostgreSQL installation
14 using initdb(1). Note that this can be overrided when creating a
15 database using createdb(1) or create database SQL command. So you
16 could have multiple databases with different encoding system.
17
18 MB also fixes some problems concerning with 8-bit single byte
19 character sets including ISO8859. (I would not say all of problems
20 have been fixed. I just confirmed that the regression test ran fine
21 and a few French characters could be used with the patch. Please let
22 me know if you find any problem while using 8-bit characters)
23
24 1. How to use
25
26 create src/Makefile.custom with a line including:
27
28         MB=encoding_system
29
30 or run configure with the mb option:
31
32         % configure --with-mb=encoding_system
33
34 where encoding_system is one of:
35
36         EUC_JP                  Japanese EUC
37         EUC_CN                  Chinese EUC
38         EUC_KR                  Korean EUC
39         EUC_TW                  Taiwan EUC
40         UNICODE                 Unicode(UTF-8)
41         MULE_INTERNAL           Mule internal
42         LATIN1                  ISO 8859-1 English and some European languages
43         LATIN2                  ISO 8859-2 English and some European languages
44         LATIN3                  ISO 8859-3 English and some European languages
45         LATIN4                  ISO 8859-4 English and some European languages
46         LATIN5                  ISO 8859-5 English and some European languages
47
48 Example:
49
50         % cat Makefile.custom
51         MB=EUC_JP
52
53         or
54
55         % configure --with-mb=EUC_JP
56
57 If MB is disabled, nothing is changed except better supporting for
58 8-bit single byte character sets.
59
60 2. How to set encoding
61
62 initdb command defines the default encoding for a PostgreSQL
63 installation. For example:
64
65         % initdb -e EUC_JP
66
67 sets the default encoding to EUC_JP(Extended Unix Code for Japanese).
68 Note that you can use "-pgencoding" instead of "-e" if you like longer
69 option string:-) If no -e or -pgencoding option is given, the encoding
70 specified at the compile time is used.
71
72 You can create a database with a different encoding.
73
74         % createdb -E EUC_KR korean
75
76 will create a database named "korean" with EUC_KR encoding. The
77 another way to accomplish this is to use a SQL command:
78
79         CREATE DATABASE korean WITH ENCODING = 'EUC_KR';
80
81 3. PGCLIENTENCODING
82
83 If an environment variable PGCLIENTENCODING is defined on the
84 frontend, automatic encoding translation is done by the backend. For
85 example, if the backend has been compiled with MB=EUC_JP and
86 PGCLIENTENCODING=SJIS(Shift JIS: yet another Japanese encoding
87 system), then any SJIS strings coming from the frontend would be
88 translated to EUC_JP before going into the parser. Outputs from the
89 backend would be translated to SJIS of course.
90
91 Supported encodings for PGCLIENTENCODING are:
92
93         EUC_JP                  Japanese EUC
94         SJIS                    Yet another Japanese encoding
95         EUC_CN                  Chinese EUC
96         EUC_KR                  Korean EUC
97         EUC_TW                  Taiwan EUC
98         MULE_INTERNAL           Mule internal
99         LATIN1                  ISO 8859-1 English and some European languages
100         LATIN2                  ISO 8859-2 English and some European languages
101         LATIN3                  ISO 8859-3 English and some European languages
102         LATIN4                  ISO 8859-4 English and some European languages
103         LATIN5                  ISO 8859-5 English and some European languages
104
105 Note that UNICODE is not supported(yet). Also note that the
106 translation is not always possible. Suppose you choose EUC_JP for the
107 backend, LATIN1 for the frotend, then some Japanese characters cannot
108 be translated into latin. In this case, a letter cannot be represented
109 in the Latin character set, would be transformed as:
110
111         (HEXA DECIMAL)
112
113 3. SET CLIENT_ENCODING TO command
114
115 Actually setting the frontend side encoding information is done by a
116 new command:
117
118         SET CLIENT_ENCODING TO 'encoding';
119
120 where encoding is one of the encodings those can be set to
121 PGCLIENTENCODING. Also you can use SQL92 syntax "SET NAMES" for this
122 purpose:
123
124         SET NAMES 'encoding';
125
126 To query the current the frontend encoding:
127
128         SHOW CLIENT_ENCODING;
129
130 To return to the default encoding:
131
132         RESET CLIENT_ENCODING;
133
134 This would reset the frontend encoding to same as the backend
135 encoding, thus no endoing translation would be performed.
136
137 4. References
138
139 These are good sources to start learning various kind of encoding
140 systems.
141
142 ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/cjk.inf
143         Detailed explanations of EUC_JP, EUC_CN, EUC_KR, EUC_TW
144         appear in section 3.2.
145
146 Unicode: http://www.unicode.org/
147         The homepage of UNICODE.
148
149         RFC 2044
150         UTF-8 is defined here.
151
152 5. History
153
154 Jul 22, 1998
155         * determine encoding at initdb/createdb rather than compile time
156         * support for PGCLIENTENCODING when issuing COPY command
157         * support for SQL92 syntax "SET NAMES"
158         * support for LATIN2-5
159         * add UNICODE regression test case
160         * new test suite for MB
161         * clean up source files
162
163 Jun 5, 1998
164         * add support for the encoding translation between the backend
165           and the frontend
166         * new command SET CLIENT_ENCODING etc. added
167         * add support for LATIN1 character set
168         * enhance 8 bit cleaness
169
170 April 21, 1998 some enhancements/fixes
171         * character_length(), position(), substring() are now aware of 
172           multi-byte characters
173         * add octet_length()
174         * add --with-mb option to configure
175         * new regression tests for EUC_KR
176           (contributed by "Soonmyung. Hong" <hong@lunaris.hanmesoft.co.kr>)
177         * add some test cases to the EUC_JP regression test
178         * fix problem in regress/regress.sh in case of System V
179         * fix toupper(), tolower() to handle 8bit chars
180
181 Mar 25, 1998 MB PL2 is incorporated into PostgreSQL 6.3.1
182
183 Mar 10, 1998 PL2 released
184         * add regression test for EUC_JP, EUC_CN and MULE_INTERNAL
185         * add an English document (this file)
186         * fix problems concerning 8-bit single byte characters
187
188 Mar 1, 1998 PL1 released