Each simple character set has a configuration file located in
sql/share/charsets directory. For a
character set named
MYSYS, the file
<map> array elements to list
character set properties.
elements appear within these elements:
<ctype>defines attributes for each character.
<upper>list the lowercase and uppercase characters.
<unicode>maps 8-bit character values to Unicode values.
<collation>elements indicate character ordering for comparison and sorting, one element per collation. Binary collations need no
<map>element because the character codes themselves provide the ordering.
For a complex character set as implemented in a
file in the
strings directory, there are
and so forth. Not every complex character set has all of the
arrays. See also the existing
files for examples. See the
CHARSET_INFO.txt file in the
strings directory for additional
Most of the arrays are indexed by character value and have 256
<ctype> array is indexed
by character value + 1 and has 257 elements. This is a legacy
convention for handling
<ctype> array elements are bit values.
Each element describes the attributes of a single character in
the character set. Each attribute is associated with a bitmask,
as defined in
#define _MY_U 01 /* Upper case */ #define _MY_L 02 /* Lower case */ #define _MY_NMR 04 /* Numeral (digit) */ #define _MY_SPC 010 /* Spacing character */ #define _MY_PNT 020 /* Punctuation */ #define _MY_CTR 040 /* Control character */ #define _MY_B 0100 /* Blank */ #define _MY_X 0200 /* heXadecimal digit */
<ctype> value for a given character
should be the union of the applicable bitmask values that
describe the character. For example,
an uppercase character (
_MY_U) as well as a
hexadecimal digit (
_MY_X), so its
ctype value should be defined like this:
ctype['A'+1] = _MY_U | _MY_X = 01 | 0200 = 0201
The bitmask values in
m_ctype.h are octal
values, but the elements of the
be written as hexadecimal values.
<upper> arrays hold the lowercase and
uppercase characters corresponding to each member of the
character set. For example:
lower['A'] should contain 'a' upper['a'] should contain 'A'
<collation> array indicates how
characters should be ordered for comparison and sorting
purposes. MySQL sorts characters based on the values of this
information. In some cases, this is the same as the
<upper> array, which means that sorting
is case-insensitive. For more complicated sorting rules (for
complex character sets), see the discussion of string collating
in Section 10.13.2, “String Collating Support for Complex Character Sets”.