views:

288

answers:

1

I've been working with UTF-8 characters in my db, and have been using php inconv function to translate characters from utf-8 to ascii before putting them into the database.

This way, I thought, I would just translate a query into ASCII before querying the database. However, now I am seeing results which lead me to believe that mysql does this translation for me.

Does anybody know if that is correct, and I can skip the whole inconv in php (which isn't very effective anyway).

As an example, a search for 'lësci' returns 'Lesci' so that leads me to believe that a translation to ASCII is happening at some point.

The table is encoded with utf_8_unicode_ci. The field is varchar(255) with a fulltext index. The query is fairly simple "SELECT * FROM users WHERE name='lësci'" returns both 'lësci' and 'Lesci'.

+1  A: 

I assume you use utf8_unicode_ci collation for the index. The collation did the trick. It's not really converting everything to ASCII but it handles the mapping between accented to raw letter.

Not sure about this specific one, utf8_generic_ci may not treat them as equal because its mapping is much simpler, therefore it's faster.

ZZ Coder
that's what I was thinking, though I just realized that the index is not fulltext, just a regular index.
pedalpete