The utf32 character set is fixed length
          (like ucs2 and unlike
          utf16). utf32 uses 32
          bits for every character, unlike ucs2
          (which uses 16 bits for every character), and unlike
          utf16 (which uses 16 bits for some
          characters and 32 bits for others).
        
          utf32 takes twice as much space as
          ucs2 and more space than
          utf16, but utf32 has the
          same advantage as ucs2 that it is
          predictable for storage: The required number of bytes for
          utf32 equals the number of characters times
          4. Also, unlike utf16, there are no tricks
          for encoding in utf32, so the stored value
          equals the code value.
        
          To demonstrate how the latter advantage is useful, here is an
          example that shows how to determine a
          utf8mb4 value given the
          utf32 code value:
        
/* Assume code value = 100cc LINEAR B WHEELED CHARIOT */
CREATE TABLE tmp (utf32_col CHAR(1) CHARACTER SET utf32,
                  utf8mb4_col CHAR(1) CHARACTER SET utf8mb4);
INSERT INTO tmp VALUES (0x000100cc,NULL);
UPDATE tmp SET utf8mb4_col = utf32_col;
SELECT HEX(utf32_col),HEX(utf8mb4_col) FROM tmp;
          MySQL is very forgiving about additions of unassigned Unicode
          characters or private-use-area characters. There is in fact
          only one validity check for utf32: No code
          value may be greater than 0x10ffff. For
          example, this is illegal:
        
INSERT INTO t (utf32_column) VALUES (0x110000); /* illegal */


User Comments
Add your own comment.