Database and Chinese
Moved over to a Linode 512 system, took a while to learn all the bits and pieces of setting it up but it's up and running now on Ubuntu 10.04 and seems to be working well (thank you for the library here, great company this one, ok enough a** kissing) except for one problem.
I moved a wordpress site doing English training for Chinese students onto my new server and transfered the database over using the wpdatabase plugin which just bundles and then unbundles all the information from what I understand. However my database includes lots of Chinese simplified characters to help explain new words, slang and idioms but now those Chinese characters all show up looking like
英è¯, 英文
At first I assumed it as a collation problem as I am a little new to this but changing it to utf8generalci did nothing and after I read that just decides how it's sorted, not how it's actually displayed and stored.
So my question is, how do I enable double byte characters in my mysql database? Should it be enabled already or is there something I need to change? And if it should already be enabled… um… any ideas why all my Chinese characters wont show?
Thanks a lot for the help!
UPDATE:
So i published a new article which can be seen here
and some of the Chiense seems to work (you can see it at the bottom of the article, the tags), all of my old Chinese did not work and the strange thing is there seems to be no reason why one character did not work (钱, looks like é’± on that article) which I wrote and another that I wrote (骗子) which i also wrote did work. The other characters I copied from my girlfriend who sent them to me using QQ (Chiense MSN basically) and they all worked….
Any thoughts?
6 Replies
$db = new mysqli('localhost', 'database', null, 'database');
if (mysqli_connect_errno()) {
$db = null;
} else {
$db->set_charset('utf8');
}
@BarkerJr:
You should check where the mysql connection is defined. Here's what I do so I can fetch Chinese text:
$db = new mysqli('localhost', 'database', null, 'database'); if (mysqli_connect_errno()) { $db = null; } else { $db->set_charset('utf8'); }
Any idea where that would be located? In the Wordpress main files?
@hoopycat:
I'm wondering if that wpdatabase plugin might not be Unicode-aware… it sounds like the corruption happened on either the export or the import. (This wouldn't be the first time.)
The database is still on my old server, though it's a little out of date now… maybe will trya nd see if transfering manually works better.