Each simple character set has a configuration file located in the
sql/share/charsets directory. For a character set named
MYSYS, the file is named
. It uses
array elements to list character set properties.
<map> elements appear within
<ctype> defines attributes for each character.
<upper> list the lowercase and uppercase characters.
<unicode> maps 8-bit character values to Unicode
<collation> elements indicate character ordering
for comparisons and sorts, 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
ctype- file in the
directory, there are corresponding arrays:
to_lower_, and so forth. Not every complex character set has
all of the arrays. See also the existing
ctype-*.c files for examples. See the
CHARSET_INFO.txt file in the
strings directory for
Most of the arrays are indexed by character value and have 256 elements. The
<ctype> array is indexed by character value + 1 and has 257 elements. This is a legacy convention
<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,
'A' is an uppercase
_MY_U) as well as a hexadecimal digit (
_MY_X), so its
ctype value should be defined like
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
<ctype> array in
should 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.3.2, "String
Collating Support for Complex Character Sets".