Source code editor What Is Ajax
MySQL supports 70+ collations for 30+ character sets. This section indicates which character sets MySQL supports. There is one subsection for each group of related character sets. For each character set, the allowable collations are listed.
You can always list the available character sets and their default collations with the
SHOW CHARACTER SET statement:
SHOW CHARACTER SET;+----------+-----------------------------+---------------------+ | Charset | Description | Default collation | +----------+-----------------------------+---------------------+ | big5 | Big5 Traditional Chinese | big5_chinese_ci | | dec8 | DEC West European | dec8_swedish_ci | | cp850 | DOS West European | cp850_general_ci | | hp8 | HP West European | hp8_english_ci | | koi8r | KOI8-R Relcom Russian | koi8r_general_ci | | latin1 | cp1252 West European | latin1_swedish_ci | | latin2 | ISO 8859-2 Central European | latin2_general_ci | | swe7 | 7bit Swedish | swe7_swedish_ci | | ascii | US ASCII | ascii_general_ci | | ujis | EUC-JP Japanese | ujis_japanese_ci | | sjis | Shift-JIS Japanese | sjis_japanese_ci | | hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | | tis620 | TIS620 Thai | tis620_thai_ci | | euckr | EUC-KR Korean | euckr_korean_ci | | koi8u | KOI8-U Ukrainian | koi8u_general_ci | | gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | | greek | ISO 8859-7 Greek | greek_general_ci | | cp1250 | Windows Central European | cp1250_general_ci | | gbk | GBK Simplified Chinese | gbk_chinese_ci | | latin5 | ISO 8859-9 Turkish | latin5_turkish_ci | | armscii8 | ARMSCII-8 Armenian | armscii8_general_ci | | utf8 | UTF-8 Unicode | utf8_general_ci | | ucs2 | UCS-2 Unicode | ucs2_general_ci | | cp866 | DOS Russian | cp866_general_ci | | keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | | macce | Mac Central European | macce_general_ci | | macroman | Mac West European | macroman_general_ci | | cp852 | DOS Central European | cp852_general_ci | | latin7 | ISO 8859-13 Baltic | latin7_general_ci | | cp1251 | Windows Cyrillic | cp1251_general_ci | | cp1256 | Windows Arabic | cp1256_general_ci | | cp1257 | Windows Baltic | cp1257_general_ci | | binary | Binary pseudo charset | binary | | geostd8 | GEOSTD8 Georgian | geostd8_general_ci | | cp932 | SJIS for Windows Japanese | cp932_japanese_ci | | eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | +----------+-----------------------------+---------------------+
In cases where a character set has multiple collations, it might not be clear which collation is most suitable for a given application. To avoid choosing the wrong collation, it can be helpful to perform some comparisons with representative data values to make sure that a given collation sorts values the way you expect.
MySQL has two Unicode character sets. You can store text in about 650 languages using these character sets.
ucs2 (UCS-2 Unicode) collations:
utf8 (UTF-8 Unicode) collations:
The MySQL implementation of UCS-2 stores characters in big-endian byte order and does not use a byte order mark (BOM) at the beginning of UCS-2 values. Other database systems might use little-ending byte order or a BOM, in which case conversion of UCS-2 values will need to be performed when transferring data between those systems and MySQL.
Note that in the
J compare as equals, and
V compare as equals.
MySQL implements the
utf8_unicode_ci collation according to the Unicode Collation Algorithm (UCA) described at http://www.unicode.org/reports/tr10/. The collation uses the version-4.0.0 UCA weight keys: http://www.unicode.org/Public/UCA/4.0.0/allkeys-4.0.0.txt. The following discussion uses
utf8_unicode_ci, but it is also true for
utf8_unicode_ci collation has only partial support for the Unicode Collation Algorithm. Some characters are not supported yet. Also, combining marks are not fully supported. This affects primarily Vietnamese, Yoruba, and some smaller languages such as Navajo.
The most significant feature in
utf8_unicode_ci is that it supports expansions; that is, when one character compares as equal to combinations of other characters. For example, in German and some other languages ‘
Я’ is equal to ‘
utf8_general_ci is a legacy collation that does not support expansions. It can make only one-to-one comparisons between characters. This means that comparisons for the
utf8_general_ci collation are faster, but slightly less correct, than comparisons for
For example, the following equalities hold in both
Д = A Ц = O Ь = U
A difference between the collations is that this is true for
Я = s
Whereas this is true for
Я = ss
MySQL implements language-specific collations for the
utf8 character set only if the ordering with
utf8_unicode_ci does not work well for a language. For example,
utf8_unicode_ci works fine for German and French, so there is no need to create special
utf8 collations for these two languages.
utf8_general_ci also is satisfactory for both German and French, except that ‘
Я’ is equal to ‘
s’, and not to ‘
ss’. If this is acceptable for your application, then you should use
utf8_general_ci because it is faster. Otherwise, use
utf8_unicode_ci because it is more accurate.
utf8_swedish_ci, like other
utf8 language-specific collations, is derived from
utf8_unicode_ci with additional language rules. For example, in Swedish, the following relationship holds, which is not something expected by a German or French speaker:
Ь = Y < Ц
utf8_spanish2_ci collations correspond to modern Spanish and traditional Spanish, respectively. In both collations, ‘
с’ (n-tilde) is a separate letter between ‘
n’ and ‘
o’. In addition, for traditional Spanish, ‘
ch’ is a separate letter between ‘
c’ and ‘
d’, and ‘
ll’ is a separate letter between ‘
l’ and ‘
Western European character sets cover most West European languages, such as French, Spanish, Catalan, Basque, Portuguese, Italian, Albanian, Dutch, German, Danish, Swedish, Norwegian, Finnish, Faroese, Icelandic, Irish, Scottish, and English.
ascii (US ASCII) collations:
cp850 (DOS West European) collations:
dec8 (DEC Western European) collations:
hp8 (HP Western European) collations:
latin1 (cp1252 West European) collations:
latin1 is the default character set. MySQL's
latin1 is the same as the Windows
cp1252 character set. This means it is the same as the official
ISO 8859-1 or IANA (Internet Assigned Numbers Authority)
latin1, except that IANA
latin1 treats the code points between
0x9f as “undefined,” whereas
cp1252, and therefore MySQL's
latin1, assign characters for those positions. For example,
0x80 is the Euro sign. For the “undefined” entries in
cp1252, MySQL translates
0x81 to Unicode
latin1_swedish_ci collation is the default that probably is used by the majority of MySQL customers. Although it is frequently said that it is based on the Swedish/Finnish collation rules, there are Swedes and Finns who disagree with this statement.
latin1_german2_ci collations are based on the DIN-1 and DIN-2 standards, where DIN stands for Deutsches Institut fьr Normung (the German equivalent of ANSI). DIN-1 is called the “dictionary collation” and DIN-2 is called the “phone book collation.”
latin1_german1_ci (dictionary) rules:
Д = A Ц = O Ь = U Я = s
latin1_german2_ci (phone-book) rules:
Д = AE Ц = OE Ь = UE Я = ss
latin1_spanish_ci collation, ‘
с’ (n-tilde) is a separate letter between ‘
n’ and ‘
macroman (Mac West European) collations:
swe7 (7bit Swedish) collations:
MySQL provides some support for character sets used in the Czech Republic, Slovakia, Hungary, Romania, Slovenia, Croatia, Poland, and Serbia (Latin).
cp1250 (Windows Central European) collations:
cp852 (DOS Central European) collations:
keybcs2 (DOS Kamenicky Czech-Slovak) collations:
latin2 (ISO 8859-2 Central European) collations:
macce (Mac Central European) collations:
South European and Middle Eastern character sets supported by MySQL include Armenian, Arabic, Georgian, Greek, Hebrew, and Turkish.
armscii8 (ARMSCII-8 Armenian) collations:
cp1256 (Windows Arabic) collations:
geostd8 (GEOSTD8 Georgian) collations:
greek (ISO 8859-7 Greek) collations:
hebrew (ISO 8859-8 Hebrew) collations:
latin5 (ISO 8859-9 Turkish) collations:
The Baltic character sets cover Estonian, Latvian, and Lithuanian languages.
cp1257 (Windows Baltic) collations:
latin7 (ISO 8859-13 Baltic) collations:
The Cyrillic character sets and collations are for use with Belarusian, Bulgarian, Russian, Ukrainian, and Serbian (Cyrillic) languages.
cp1251 (Windows Cyrillic) collations:
cp866 (DOS Russian) collations:
koi8r (KOI8-R Relcom Russian) collations:
koi8u (KOI8-U Ukrainian) collations:
The Asian character sets that we support include Chinese, Japanese, Korean, and Thai. These can be complicated. For example, the Chinese sets must allow for thousands of different characters. See Section 10.10.7.1, “The
cp932 Character Set”, for additional information about the
sjis character sets.
For answers to some common questions and problems relating support for Asian character sets in MySQL, see Section A.11, “MySQL 5.0 FAQ — MySQL Chinese, Japanese, and Korean Character Sets”.
big5 (Big5 Traditional Chinese) collations:
cp932 (SJIS for Windows Japanese) collations:
eucjpms (UJIS for Windows Japanese) collations:
euckr (EUC-KR Korean) collations:
gb2312 (GB2312 Simplified Chinese) collations:
gbk (GBK Simplified Chinese) collations:
sjis (Shift-JIS Japanese) collations:
tis620 (TIS620 Thai) collations:
ujis (EUC-JP Japanese) collations:
In MySQL, the
sjis character set corresponds to the
Shift_JIS character set defined by IANA, which supports JIS X0201 and JIS X0208 characters. (See http://www.iana.org/assignments/character-sets.)
However, the meaning of “SHIFT JIS” as a descriptive term has become very vague and it often includes the extensions to
Shift_JIS that are defined by various vendors.
For example, “SHIFT JIS” used in Japanese Windows environments is a Microsoft extension of
Shift_JIS and its exact name is
Microsoft Windows Codepage : 932 or
cp932. In addition to the characters supported by
cp932 supports extension characters such as NEC special characters, NEC selected — IBM extended characters, and IBM extended characters.
Many Japanese users have experienced problems using these extension characters. These problems stem from the following factors:
MySQL automatically converts character sets.
Character sets are converted via Unicode (
sjis character set does not support the conversion of these extension characters.
There are several conversion rules from so-called “SHIFT JIS” to Unicode, and some characters are converted to Unicode differently depending on the conversion rule. MySQL supports only one of these rules (described later).
cp932 character set is designed to solve these problems. It is available as of MySQL 5.0.3.
Because MySQL supports character set conversion, it is important to separate IANA
cp932 into two different character sets because they provide different conversion rules.
cp932 differ from
cp932 character set differs from
sjis in the following ways:
cp932 supports NEC special characters, NEC selected — IBM extended characters, and IBM selected characters.
cp932 characters have two different code points, both of which convert to the same Unicode code point. When converting from Unicode back to
cp932, one of the code points must be selected. For this “round trip conversion,” the rule recommended by Microsoft is used. (See http://support.microsoft.com/kb/170559/EN-US/.)
The conversion rule works like this:
If the character is in both JIS X 0208 and NEC special characters, use the code point of JIS X 0208.
If the character is in both NEC special characters and IBM selected characters, use the code point of NEC special characters.
If the character is in both IBM selected characters and NEC selected — IBM extended characters, use the code point of IBM extended characters.
The table shown at http://www.microsoft.com/globaldev/reference/dbcs/932.htm provides information about the Unicode values of
cp932 characters. For
cp932 table entries with characters under which a four-digit number appears, the number represents the corresponding Unicode (
ucs2) encoding. For table entries with an underlined two-digit value appears, there is a range of
cp932 character values that begin with those two digits. Clicking such a table entry takes you to a page that displays the Unicode value for each of the
cp932 characters that begin with those digits.
The following links are of special interest. They correspond to the encodings for the following sets of characters:
NEC special characters:
NEC selected — IBM extended characters:
IBM selected characters:
Starting from version 5.0.3,
cp932 supports conversion of user-defined characters in combination with
eucjpms, and solves the problems with
ujis conversion. For details, please refer to http://www.opengroup.or.jp/jvc/cde/sjis-euc-e.html.
For some characters, conversion to and from
ucs2 is different for
cp932. The following tables illustrate these differences.
Users of any Japanese character sets should be aware that using
--skip-character-set-client-handshake) has an important effect. See Section 5.2.2, “Command Options”.
Source code editor What Is Ajax