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

后端 未结 3 1047
灰色年华
灰色年华 2021-02-19 17:30

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 17:56

    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.

提交回复
热议问题