I want a UTF8 collation for supporting:
Does UTF8_GENERAL_CI
support all these Languages?
If you elect to use UTF-8 as your collation, always use utf8mb4 (specifically utf8mb4_unicode_ci). You should not use UTF-8 because MySQL's UTF-8 is different from proper UTF-8 encoding. This is the case because it doesn't offer full unicode support which can lead to data loss or security issues.
The difference between utf8 and utf8mb4 is that the former can only store 3 byte characters, while the latter can store 4 byte characters. In Unicode terms, utf8 can only store characters in the Basic Multilingual Plane, while utf8mb4 can store any Unicode character.
In short: utf8_unicode_ci uses the Unicode Collation Algorithm as defined in the Unicode standards, whereas utf8_general_ci is a more simple sort order which results in "less accurate" sorting results.
Yes, that is correct. UTF-8 is an encoding for the Unicode character set, which supports pretty much every language in the world.
I think the only difference comes with sorting your results, different letters might come in a different order in other languages (accents, umlauts, etc.). Also, comparing a
to ä
might behave differently in another collation.
The _ci
suffix means sorting and comparison happens case insensitive.
http://www.collation-charts.org/ might be of interest to you.
As UTF8_GENERAL_CI
was a good decision some time ago. It has some drawbacks now.
MySQL's UTF8 actually uses 3 bytes instead of 4, which you need for symbols like emojis and new asian chars.
So MySQL has a newer charset called utf8mb4 which actually complies with UTF8 definition.
To be able fully support Asian languages you will need to choose utf8mb4.
If you care about correct sorting in multiple languages, use utf8mb4_unicode
or utf8mb4_unicode_ci
instead general.
A more detailed answer you can find in What's the difference between utf8_general_ci and utf8_unicode_ci
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With