Adding a Character Set
806
a suffix of
general_ci
(general, case insensitive). It is possible for the binary collation to be the
default collation, but usually they are different. The default collation should have a
primary
flag.
The binary collation should have a
binary
flag.
You must assign a unique ID number to each collation, chosen from the range 1 to 254. To find the
maximum of the currently used collation IDs, use this query:
SELECT MAX(ID) FROM INFORMATION_SCHEMA.COLLATIONS;
2. This step depends on whether you are adding a simple or complex character set. A simple
character set requires only a configuration file, whereas a complex character set requires C source
file that defines collation functions, multi-byte functions, or both.
For a simple character set, create a configuration file,
MYSET.xml
, that describes the character
set properties. Create this file in the
sql/share/charsets
directory. You can use a copy of
latin1.xml
as the basis for this file. The syntax for the file is very simple:
• Comments are written as ordinary XML comments (
<!-- text -->
).
• Words within
<map>
array elements are separated by arbitrary amounts of whitespace.
• Each word within
<map>
array elements must be a number in hexadecimal format.
• The
<map>
array element for the
<ctype>
element has 257 words. The other
<map>
array
elements after that have 256 words. See
Section 10.3.1, “Character Definition Arrays”
.
• For each collation listed in the
<charset>
element for the character set in
Index.xml
,
MYSET.xml
must contain a
<collation>
element that defines the character ordering.
For a complex character set, create a C source file that describes the character set properties and
defines the support routines necessary to properly perform operations on the character set:
• Create the file
ctype-MYSET.c
in the
strings
directory. Look at one of the existing
ctype-
*.c
files (such as
ctype-big5.c
) to see what needs to be defined. The arrays in your file must
have names like
ctype_MYSET
,
to_lower_MYSET
, and so on. These correspond to the arrays
for a simple character set. See
Section 10.3.1, “Character Definition Arrays”
.
• For each
<collation>
element listed in the
<charset>
element for the character set in
Index.xml
, the
ctype-MYSET.c
file must provide an implementation of the collation.
• If the character set requires string collating functions, see
Section 10.3.2, “String Collating
Support for Complex Character Sets”
.
• If the character set requires multi-byte character support, see
Section 10.3.3, “Multi-Byte
Character Support for Complex Character Sets”
.
3. Modify the configuration information. Use the existing configuration information as a guide to adding
information for
MYSYS
. The example here assumes that the character set has default and binary
collations, but more lines are needed if
MYSET
has additional collations.
a. Edit
mysys/charset-def.c
, and “register” the collations for the new character set.
Add these lines to the “declaration” section:
#ifdef HAVE_CHARSET_
MYSET
extern CHARSET_INFO my_charset_
MYSET
_general_ci;
extern CHARSET_INFO my_charset_
MYSET
_bin;
#endif
Add these lines to the “registration” section:
#ifdef HAVE_CHARSET_
MYSET
add_compiled_collation(&my_charset_
MYSET
_general_ci);
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...