I recently upgraded WAMPServer and now in phpMyAdmin, I see both collations utf8_unicode_ci
and utf8_unicode_520_ci
. I was using "utf8_unicode_ci" for Turkish applications, but I wonder what is different in the new *_520
collation?
问题:
回答1:
As documented under Collation Names:
Unicode collation names may include a version number to indicate the version of the Unicode Collation Algorithm (UCA) on which the collation is based. UCA-based collations without a version number in the name use the version-4.0.0 UCA weight keys: http://www.unicode.org/Public/UCA/4.0.0/allkeys-4.0.0.txt. A collation name such as
utf8_unicode_520_ci
is based on UCA 5.2.0 weight keys: http://www.unicode.org/Public/UCA/5.2.0/allkeys.txt.
回答2:
As you can read here (thanks user3399549 for link) there is problem with sorting/comparing polish letter "Ł" (L with stroke) (lower case: "ł"; html esc: ł
and Ł
) here Peter Gulutzan explain differences between collocations:
We have these collations and rules for Ł :
utf8_polish_ci Ł greater than L and less than M
utf8_unicode_ci Ł greater than L and less than M
utf8_unicode_520_ci Ł equal to L
utf8_general_ci Ł greater than Z
In polish language letter Ł is after letter L and before M. We can write this in following way (for clarify):
L < Ł < M
and
L != Ł
So to avoid this kind of problems (with sorting/comapring) use utf8_unicode_ci
.
回答3:
If you want only Turkish, then consider utf8_turkish_ci
. Here are most of the differences (taken from http://mysql.rjweb.org/utf8_collations.html ):
utf8 : utf8_turkish_ci A=a=ª=À=Á=Á=Â=Ã=Ä=Å=à=á=á=â=ã=ä=å=Ā=ā=Ą=ą Aa ae az Æ=æ
utf8 : utf8_unicode_520_ci A=a=ª=À=Á=Á=Â=Ã=Ä=Å=à=á=á=â=ã=ä=å=Ā=ā=Ą=ą Aa ae=Æ=æ az
utf8 : utf8_unicode_ci A=a=ª=À=Á=Á=Â=Ã=Ä=Å=à=á=á=â=ã=ä=å=Ā=ā=Ą=ą Aa ae az Æ=æ
utf8 : utf8_turkish_ci B=b C=c=Č=č ch cz Ç=ç D=d=Ď=ď dz Ð=ð
utf8 : utf8_unicode_520_ci B=b C=c=Ç=ç=Č=č ch cz D=d=Ð=ð=Ď=ď dz
utf8 : utf8_unicode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f8_turkish_ci P=p Q=q R=r=Ř=ř S=s=Š=Š=š=š sh ss=ß sz Ş=ş
utf8 : utf8_unicode_520_ci P=p Q=q R=r=Ř=ř S=s=Ş=ş=Š=Š=š=š sh ss=ß sz
utf8 : utf8_unicode_ci P=p Q=q R=r=Ř=ř S=s=Ş=ş=Š=Š=š=š sh ss=ß sz
utf8 : utf8_turkish_ci T=t=Ť=ť TM=tm=™ tz U=u=Ù=Ú=Ú=Û=ù=ú=ú=û=Ū=ū=Ů=ů=Ų=ų ue uz Ü=ü V=v
utf8 : utf8_unicode_520_ci T=t=Ť=ť TM=tm=™ tz U=u=Ù=Ú=Ú=Û=Ü=ù=ú=ú=û=ü=Ū=ū=Ů=ů=Ų=ų ue uz V=v
utf8 : utf8_unicode_ci T=t=Ť=ť TM=tm=™ tz U=u=Ù=Ú=Ú=Û=Ü=ù=ú=ú=û=ü=Ū=ū=Ů=ů=Ų=ų ue uz V=v
utf8 : utf8_turkish_ci W=w X=x Y=y=Ý=Ý=ý=ý=ÿ=Ÿ yz
utf8 : utf8_unicode_520_ci W=w X=x Y=y=Ý=Ý=ý=ý=ÿ=Ÿ yz
utf8 : utf8_unicode_ci W=w X=x Y=y=Ý=Ý=ý=ý=ÿ=Ÿ yz
utf8 : utf8_turkish_ci Z=z=Ž=Ž=ž=ž zh zz Þ=þ
utf8 : utf8_unicode_520_ci Z=z=Ž=Ž=ž=ž zh zz Þ=þ
utf8 : utf8_unicode_ci Z=z=Ž=Ž=ž=ž zh zz Þ=þ
Notice how Æ, Ç, Ð, Ğ, etc, are sorted differently in the different collations.
520 probably will not impact normal text, especially just Turkish. For example, Turkish and 520 consider Ð
to be a separate letter, but utf8_unicode_ci
treats it equal to D
. It looks like 520 is 'closer' to turkish, but not identical for all the letters.