1.utf8 and utf8mb4 (UTF8 most bytes 4)
- UTFMB4 character encoding added after MySQL 5.5.3
- Supports BMP (Basic multilingual Plane, basic multilingual Plane) and supplemental characters
- Use up to four bytes of stored characters
UTF8MB4 is a superset of UTF8 and fully compatible with UTF8, capable of storing more characters in four bytes.
The standard UTF-8 character set encoding is the ability to encode 21-bit characters using 1-4 bytes, which contains almost all of the world's visible languages.
MySQL implements the UTF8 maximum use of 3 characters , contains most characters but not all. For example, emoji and some less commonly used Chinese characters, such as "Villa", these require four bytes to encode is not supported.
2. Character set, connection character set, sort character set
UTF8MB4 corresponds to a sorted character set with Utf8mb4_unicode_ci, Utf8mb4_general_ci.
Comparison of Utf8mb4_unicode_ci and Utf8mb4_general_ci:
- Accuracy:
- UTF8MB4_UNICODE_CI is a standard-based Unicode for sorting and comparison, allowing for precise sorting between various languages
- Utf8mb4_general_ci does not implement Unicode collations, and in the case of certain special languages or character sets, the sort results may be inconsistent.
- However, in most cases, the order of these special characters does not need to be so precise.
- Performance
- Utf8mb4_general_ci faster when comparing and sorting
- Utf8mb4_unicode_ci in special cases, the Unicode collation implements a slightly more complex sorting algorithm in order to handle special characters.
- But in the vast majority of cases, this kind of complex comparisons will not occur. Instead of choosing which collation, the user should be concerned that the character set and collation need to be unified in the DB.
UTF8MB4, Utf8mb4_unicode_ci, utf8mb4_general_ci in MySQL