How to make MySQL aware of multi-byte characters in LIKE and REGEXP?

后端 未结 3 753
野趣味
野趣味 2021-02-19 17:27

I have a MySQL table with two columns, both utf8_unicode_ci collated. It contains the following rows. Except for ASCII, the second field also contains Unicode codepoints like U+

3条回答
  •  抹茶落季
    2021-02-19 18:00

    I'm not dead-set on using MySQL

    Postgres seems to handle it quite fine:

    test=# select 'ˌˈʔ' like '___';
     ?column? 
    ----------
     t
    (1 row)
    
    test=# select 'ˌˈʔ' ~ '^.{3}$';
     ?column? 
    ----------
     t
    (1 row)
    

    If you go down that road, note that in Postgres' ilike operator matches that of MySQL's like. (In Postgres, like is case-sensitive.)


    For the MySQL-specific solution, you mind be able to work around by binding some user-defined function (maybe bind the ICU library?) into MySQL.

提交回复
热议问题