Which MySQL collation compares e.g. é and e as equal?

我与影子孤独终老i 提交于 2019-12-10 20:07:43

问题


EDIT: if no such collation exists, I can work around it if MySQL has a function which will convert strings into ASCII equivalents e.g. FUNC('Være')='Vaere' -- there might be several such functions, one for each alphabet, which would be a hassle but acceptable if effective.


I need a MySQL5 collation which will compare accented characters as equivalent, irrespective of accents. e.g. "fêter" should be considered equal to "feter" and "eł" should match "el"

Ideally this wouldn't be limited to single-character substitutions, e.g. "For At Være Som Man Bør" should be considered equal to "For At Vaere Som Man Bor". WHERE name LIKE '%ere%' should also match it.

I see there are collations for spanish/polish/etc, but I need one collation to cover all latin-like alphabets (not Arabic or Asian ones etc). The strings are stored as UTF-8.

Which collation should I use?


回答1:


Since you said you're using the utf8 characters set, the answer to your original question is "all of them except utf8_bin".

In all of these collations you will find that 'e' = 'ê'.

However, I don't know of any collations where 'æ' = 'ae' or 'ø' = 'o'.

 utf8_czech_ci
 utf8_danish_ci
 utf8_esperanto_ci
 utf8_estonian_ci
 utf8_general_ci
 utf8_hungarian_ci
 utf8_icelandic_ci
 utf8_latvian_ci
 utf8_lithuanian_ci
 utf8_persian_ci
 utf8_polish_ci
 utf8_roman_ci
 utf8_romanian_ci
 utf8_sinhala_ci
 utf8_slovak_ci
 utf8_slovenian_ci
 utf8_spanish_ci
 utf8_spanish2_ci
 utf8_swedish_ci
 utf8_turkish_ci
 utf8_unicode_ci



回答2:


utf8-general-ci would be the closest one: http://www.collation-charts.org/mysql60/mysql604.utf8_general_ci.european.html

Also note that as of MySQL 5.0 you can create your own collations. http://dev.mysql.com/doc/refman/5.0/en/adding-collation.html http://forge.mysql.com/wiki/How_to_Add_a_Collation



来源:https://stackoverflow.com/questions/9518681/which-mysql-collation-compares-e-g-%c3%a9-and-e-as-equal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!