开发者

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开发者_Python百科 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


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).


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜