mysql> INSERT INTO t1 VALUES (’a’),(’A’),(0x81B0); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> SELECT c1, HEX(c1), HEX(WEIGHT_STRING(c1)) FROM t1; +------+---------+------------------------+ | c1 | HEX(c1) | HEX(WEIGHT_STRING(c1)) | +------+---------+------------------------+ | a | 61 | 41 | | A | 41 | 41 | | 膰 | 81B0 | C286 | +------+---------+------------------------+ 3 rows in set (0.00 sec) 

For implementation instructions, see Section 10.13, “Adding a Character Set” . 

## Collations for Unicode multibyte character sets 

Some of these collations are based on the Unicode Collation Algorithm (UCA), others are not. 

Non-UCA collations have a one-to-one mapping from character code to weight. In MySQL, such collations are case-insensitive and accent-insensitive. utf8_general_ci  is an example: ’a’ , ’A’ , ’À’ , and ’Æ’ each have different character codes but all have a weight of 0x0041  and compare as equal. 

mysql> SET NAMES ’utf8’ COLLATE ’utf8_general_ci’; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE t1 (c1 CHAR(1) CHARACTER SET UTF8 COLLATE utf8_general_ci); Query OK, 0 rows affected (0.01 sec) mysql> INSERT INTO t1 VALUES (’a’),(’A’),(’À’),(’Æ’); Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql> SELECT c1, HEX(c1), HEX(WEIGHT_STRING(c1)) FROM t1; +------+---------+------------------------+ | c1 | HEX(c1) | HEX(WEIGHT_STRING(c1)) | +------+---------+------------------------+ | a | 61 | 0041 | | A | 41 | 0041 | | À | C380 | 0041 | | Æ | C3A1 | 0041 | +------+---------+------------------------+ 4 rows in set (0.00 sec) 

UCA-based collations in MySQL have these properties: 

•If a character has weights, each weight uses 2 bytes (16 bits). 

•A character may have zero weights (or an empty weight). In this case, the character is ignorable. Example: "U+0000 NULL" does not have a weight and is ignorable. 

•A character may have one weight. Example: ’a’  has a weight of 0x0E33 . 

mysql> SET NAMES ’utf8’ COLLATE ’utf8_unicode_ci’; Query OK, 0 rows affected (0.05 sec) mysql> SELECT HEX(’a’), HEX(WEIGHT_STRING(’a’)); +----------+-------------------------+ | HEX(’a’) | HEX(WEIGHT_STRING(’a’)) | +----------+-------------------------+ | 61 | 0E33 | +----------+-------------------------+ 

