1998-07-24 11:32:46 +08:00
|
|
|
postgresql 6.4 multi-byte (MB) support README Jul 22 1998
|
1998-03-15 15:39:04 +08:00
|
|
|
|
|
|
|
Tatsuo Ishii
|
|
|
|
t-ishii@sra.co.jp
|
|
|
|
http://www.sra.co.jp/people/t-ishii/PostgreSQL/
|
|
|
|
|
1998-06-16 15:29:54 +08:00
|
|
|
0. Introduction
|
1998-03-15 15:39:04 +08:00
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
The MB support is intended for allowing PostgreSQL to handle
|
|
|
|
multi-byte character sets such as EUC(Extended Unix Code), Unicode and
|
|
|
|
Mule internal code. With the MB enabled you can use multi-byte
|
|
|
|
character sets in regexp ,LIKE and some functions. The encoding system
|
1998-07-24 11:32:46 +08:00
|
|
|
chosen is determined when initializing your PostgreSQL installation
|
|
|
|
using initdb(1). Note that this can be overrided when creating a
|
|
|
|
database using createdb(1) or create database SQL command. So you
|
|
|
|
could have multiple databases with different encoding system.
|
1998-03-15 15:39:04 +08:00
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
MB also fixes some problems concerning with 8-bit single byte
|
1998-03-15 15:39:04 +08:00
|
|
|
character sets including ISO8859. (I would not say all of problems
|
|
|
|
have been fixed. I just confirmed that the regression test ran fine
|
|
|
|
and a few French characters could be used with the patch. Please let
|
|
|
|
me know if you find any problem while using 8-bit characters)
|
|
|
|
|
1998-06-16 15:29:54 +08:00
|
|
|
1. How to use
|
1998-03-15 15:39:04 +08:00
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
create src/Makefile.custom with a line including:
|
1998-03-15 15:39:04 +08:00
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
MB=encoding_system
|
|
|
|
|
|
|
|
or run configure with the mb option:
|
|
|
|
|
|
|
|
% configure --with-mb=encoding_system
|
1998-03-15 15:39:04 +08:00
|
|
|
|
|
|
|
where encoding_system is one of:
|
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
EUC_JP Japanese EUC
|
|
|
|
EUC_CN Chinese EUC
|
|
|
|
EUC_KR Korean EUC
|
|
|
|
EUC_TW Taiwan EUC
|
|
|
|
UNICODE Unicode(UTF-8)
|
|
|
|
MULE_INTERNAL Mule internal
|
1998-07-24 11:32:46 +08:00
|
|
|
LATIN1 ISO 8859-1 English and some European languages
|
|
|
|
LATIN2 ISO 8859-2 English and some European languages
|
|
|
|
LATIN3 ISO 8859-3 English and some European languages
|
|
|
|
LATIN4 ISO 8859-4 English and some European languages
|
|
|
|
LATIN5 ISO 8859-5 English and some European languages
|
1998-03-15 15:39:04 +08:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
% cat Makefile.custom
|
|
|
|
MB=EUC_JP
|
|
|
|
|
|
|
|
or
|
1998-03-15 15:39:04 +08:00
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
% configure --with-mb=EUC_JP
|
|
|
|
|
|
|
|
If MB is disabled, nothing is changed except better supporting for
|
1998-03-15 15:39:04 +08:00
|
|
|
8-bit single byte character sets.
|
|
|
|
|
1998-07-24 11:32:46 +08:00
|
|
|
2. How to set encoding
|
|
|
|
|
|
|
|
initdb command defines the default encoding for a PostgreSQL
|
|
|
|
installation. For example:
|
|
|
|
|
|
|
|
% initdb -e EUC_JP
|
|
|
|
|
|
|
|
sets the default encoding to EUC_JP(Extended Unix Code for Japanese).
|
|
|
|
Note that you can use "-pgencoding" instead of "-e" if you like longer
|
|
|
|
option string:-) If no -e or -pgencoding option is given, the encoding
|
|
|
|
specified at the compile time is used.
|
|
|
|
|
|
|
|
You can create a database with a different encoding.
|
|
|
|
|
|
|
|
% createdb -E EUC_KR korean
|
|
|
|
|
|
|
|
will create a database named "korean" with EUC_KR encoding. The
|
|
|
|
another way to accomplish this is to use a SQL command:
|
|
|
|
|
|
|
|
CREATE DATABASE korean WITH ENCODING = 'EUC_KR';
|
|
|
|
|
|
|
|
3. PGCLIENTENCODING
|
1998-06-16 15:29:54 +08:00
|
|
|
|
|
|
|
If an environment variable PGCLIENTENCODING is defined on the
|
|
|
|
frontend, automatic encoding translation is done by the backend. For
|
|
|
|
example, if the backend has been compiled with MB=EUC_JP and
|
|
|
|
PGCLIENTENCODING=SJIS(Shift JIS: yet another Japanese encoding
|
|
|
|
system), then any SJIS strings coming from the frontend would be
|
|
|
|
translated to EUC_JP before going into the parser. Outputs from the
|
|
|
|
backend would be translated to SJIS of course.
|
|
|
|
|
|
|
|
Supported encodings for PGCLIENTENCODING are:
|
|
|
|
|
|
|
|
EUC_JP Japanese EUC
|
|
|
|
SJIS Yet another Japanese encoding
|
|
|
|
EUC_CN Chinese EUC
|
|
|
|
EUC_KR Korean EUC
|
|
|
|
EUC_TW Taiwan EUC
|
|
|
|
MULE_INTERNAL Mule internal
|
1998-07-24 11:32:46 +08:00
|
|
|
LATIN1 ISO 8859-1 English and some European languages
|
|
|
|
LATIN2 ISO 8859-2 English and some European languages
|
|
|
|
LATIN3 ISO 8859-3 English and some European languages
|
|
|
|
LATIN4 ISO 8859-4 English and some European languages
|
|
|
|
LATIN5 ISO 8859-5 English and some European languages
|
1998-06-16 15:29:54 +08:00
|
|
|
|
|
|
|
Note that UNICODE is not supported(yet). Also note that the
|
|
|
|
translation is not always possible. Suppose you choose EUC_JP for the
|
|
|
|
backend, LATIN1 for the frotend, then some Japanese characters cannot
|
|
|
|
be translated into latin. In this case, a letter cannot be represented
|
|
|
|
in the Latin character set, would be transformed as:
|
|
|
|
|
|
|
|
(HEXA DECIMAL)
|
|
|
|
|
|
|
|
3. SET CLIENT_ENCODING TO command
|
|
|
|
|
|
|
|
Actually setting the frontend side encoding information is done by a
|
|
|
|
new command:
|
|
|
|
|
|
|
|
SET CLIENT_ENCODING TO 'encoding';
|
|
|
|
|
|
|
|
where encoding is one of the encodings those can be set to
|
1998-07-24 11:32:46 +08:00
|
|
|
PGCLIENTENCODING. Also you can use SQL92 syntax "SET NAMES" for this
|
|
|
|
purpose:
|
|
|
|
|
|
|
|
SET NAMES 'encoding';
|
|
|
|
|
|
|
|
To query the current the frontend encoding:
|
1998-06-16 15:29:54 +08:00
|
|
|
|
|
|
|
SHOW CLIENT_ENCODING;
|
|
|
|
|
|
|
|
To return to the default encoding:
|
|
|
|
|
|
|
|
RESET CLIENT_ENCODING;
|
|
|
|
|
|
|
|
This would reset the frontend encoding to same as the backend
|
|
|
|
encoding, thus no endoing translation would be performed.
|
|
|
|
|
|
|
|
4. References
|
1998-03-15 15:39:04 +08:00
|
|
|
|
|
|
|
These are good sources to start learning various kind of encoding
|
|
|
|
systems.
|
|
|
|
|
|
|
|
ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/cjk.inf
|
|
|
|
Detailed explanations of EUC_JP, EUC_CN, EUC_KR, EUC_TW
|
|
|
|
appear in section 3.2.
|
|
|
|
|
|
|
|
Unicode: http://www.unicode.org/
|
|
|
|
The homepage of UNICODE.
|
|
|
|
|
|
|
|
RFC 2044
|
|
|
|
UTF-8 is defined here.
|
|
|
|
|
1998-06-16 15:29:54 +08:00
|
|
|
5. History
|
|
|
|
|
1998-07-24 11:32:46 +08:00
|
|
|
Jul 22, 1998
|
|
|
|
* determine encoding at initdb/createdb rather than compile time
|
|
|
|
* support for PGCLIENTENCODING when issuing COPY command
|
|
|
|
* support for SQL92 syntax "SET NAMES"
|
|
|
|
* support for LATIN2-5
|
|
|
|
* add UNICODE regression test case
|
|
|
|
* new test suite for MB
|
|
|
|
* clean up source files
|
|
|
|
|
|
|
|
Jun 5, 1998
|
1998-06-16 15:29:54 +08:00
|
|
|
* add support for the encoding translation between the backend
|
|
|
|
and the frontend
|
|
|
|
* new command SET CLIENT_ENCODING etc. added
|
|
|
|
* add support for LATIN1 character set
|
|
|
|
* enhance 8 bit cleaness
|
1998-03-15 15:39:04 +08:00
|
|
|
|
1998-04-28 01:10:50 +08:00
|
|
|
April 21, 1998 some enhancements/fixes
|
|
|
|
* character_length(), position(), substring() are now aware of
|
|
|
|
multi-byte characters
|
|
|
|
* add octet_length()
|
|
|
|
* add --with-mb option to configure
|
|
|
|
* new regression tests for EUC_KR
|
|
|
|
(contributed by "Soonmyung. Hong" <hong@lunaris.hanmesoft.co.kr>)
|
|
|
|
* add some test cases to the EUC_JP regression test
|
|
|
|
* fix problem in regress/regress.sh in case of System V
|
|
|
|
* fix toupper(), tolower() to handle 8bit chars
|
|
|
|
|
|
|
|
Mar 25, 1998 MB PL2 is incorporated into PostgreSQL 6.3.1
|
|
|
|
|
1998-03-15 15:39:04 +08:00
|
|
|
Mar 10, 1998 PL2 released
|
|
|
|
* add regression test for EUC_JP, EUC_CN and MULE_INTERNAL
|
|
|
|
* add an English document (this file)
|
|
|
|
* fix problems concerning 8-bit single byte characters
|
|
|
|
|
|
|
|
Mar 1, 1998 PL1 released
|