Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在开发一个网站,该网站将展示世界上几乎所有语言的内容。而且我在选择要在 MySQL 中定义的最佳排序规则时遇到问题。
哪一个最适合支持所有角色?还是最准确的?
还是最好将所有字符转换为unicode?
接受的答案是错误的(也许在 2009 年是正确的)。
utf8mb4_unicode_ci是用于广泛语言支持的最佳编码。
utf8mb4_unicode_ci
推理和支持证据:
你想使用utf8mb4而不是utf8因为后者只支持 3 字节字符,而你想支持 4 字节字符。(参考)
utf8mb4
utf8
和
您想使用unicode而不是general因为后者从未正确排序。(参考)
unicode
general
我通常使用 8 位 UCS/Unicode 转换格式,它适用于任何(大多数)语言
utf8_general_ci
http://dev.mysql.com/doc/refman/5.0/en/charset-unicode.html
使用utf8mb4代替 utf8
utf8mb4_general_ci => support 1, 2, 3 or 4 bytes
utf8_general_ci or utf8mb3_general_ci => support 1, 2 or 3 bytes
它将根据需要在您的磁盘上占用空间。
使用utf8mb4_unicode_cior utf8mb4_general_ci 可能会很棘手并导致意外行为。
意识到。
utf8mb4_unicode_bin如果您想避免下面这样的情况,也许是一个不错的选择。
utf8mb4_unicode_bin