Reputation: 2946
I am trying to store both English and Chinese in different fields in a single MySQL table.
lang1
for English, lang2
for Chinese.
I tried both UTF8_general_ci and UTF8_unicode_ci for the tables character set.
The Html page for input is using UTF8 as well. But for some reason the chinese characters come back as ???. Anyone know why this could be happening? I copy and pasted the chinese characters from a UTF8 page as well.
EDIT: Request Headers for the Input page:
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
The page itself sets:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
EDIT: It looks like after setting the field lang2 to utf8_general_ci, it is storing the characters properly. I was setting the table and the database collation to utf8 but missed the specific field.
Upvotes: 1
Views: 5436
Reputation: 7211
here is brief explanation for mysql character set for chinese language.
http://www.haidongji.com/2007/10/04/character-set-and-collation-for-simplified-chinese-mysql/
http://dev.mysql.com/doc/refman/5.1/en/faqs-cjk.html#qandaitem-B-11-1-3
Upvotes: 2
Reputation: 2229
here are the mysql character sets for Chinese Japanese Korean
+--------------------+---------------------------+
| CHARACTER_SET_NAME | DESCRIPTION |
+--------------------+---------------------------+
| big5 | Big5 Traditional Chinese |
| cp932 | SJIS for Windows Japanese |
| eucjpms | UJIS for Windows Japanese |
| euckr | EUC-KR Korean |
| gb2312 | GB2312 Simplified Chinese |
| gbk | GBK Simplified Chinese |
| sjis | Shift-JIS Japanese |
| ujis | EUC-JP Japanese |
+--------------------+---------------------------+
If you go with UTF-8 make sure that is the charset that your page is passing to the database. then you can set the htmlentities() to utf8_encode() so everything is talking the same language so to speak.
you can also try the fix of setting the fields storing chinese data to binary as shown in this post http://www.dodoskido.com/archives/003040-mysql-chinese-character-fix-or-how-to-make-utf8-work-for-you-pages.html
Upvotes: 2