Does a utf8

Does anyone know if a utf8_unicode_cs collation for MySQL exists? So far, my searches have come up dry. If it simply doesn't exist yet, is it fairly straight-forward to create one? Or somehow use utf8_unicode_ci or utf8_bin but "simulate" what one would expect from a utf8_unicode_cs collation?


I came across the same issue and after some Googling, it seems that MySQL doesn't include it. To "simulate it", as you put it,

1) To ensure case-sensitivity in the DB: set the table column to utf8_bin collation
This allows:

  • strict SELECTs: SELECT "Joe" will NOT return rows with "joe" / "joE" / "jOe" / etc
  • strict UNIQUE index: a column with a UNIQUE index will treat case differences as different values. For example, if a utf8_unicode_ci collation is used, inserting "Joe" on a table that already has "joe" will trigger a "Duplicate key" error. If ut8_bin is used, inserting "Joe" will work fine.
  • 2) To get the proper ordering in results: add the collation to the SQL query:

    SELECT ... ORDER BY column COLLATE utf8_unicode_ci
    
    链接地址: http://www.djcxy.com/p/25176.html

    上一篇: 通过PHP将♥插入MySQL(心脏字符)

    下一篇: 做一个utf8