Matt
Matt

Reputation: 11357

What collation should I use to store foreign characters in a table?

I'm using google translate with my website to translate short, frequently used phrases. Instead of asking google for a translation every time, I thought of caching the translations in a MySQL table.

Anyway, it works fine for latin characters, but fails for others like asian. What collation/charset would be the best to use?

Also - I've tried the default (latin1_swedish_ci) and utf8_unicode_ci

Upvotes: 0

Views: 195

Answers (2)

Your Common Sense
Your Common Sense

Reputation: 157989

Collation has nothing to do with international characters. Charset does.
Usual solution is utf8.

Dunno what do you mean "I've tried utf8_unicode_ci", but at least you have to tell database, what charset your data is. SET NAMES utf8 query can do that, if your data from google uses that charset

Upvotes: 1

Etienne de Martel
Etienne de Martel

Reputation: 36995

One of those should do the trick: http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html

Also, as seen in the MySQL documentation:

Client applications that need to communicate with the server using Unicode should set the client character set accordingly; for example, by issuing a SET NAMES 'utf8' statement.

So, if you select the utf8_unicode_ci encoding, you will need to execute a SET NAMES 'utf8' query for every connection to your database (run it after a mysql_select_db() or whatever you're using).

Upvotes: 2

Related Questions