Inserting Chinese or Other Non English character into mysql
I have a Chinese text file that’s not encoded in UTF8 , it’s encoded with gb2312 . I have been struggling to insert it into mysql. When i copy the text file & import it to mysql via phpmyadmin, it display chinese character very well, but if i use php to insert it, it display some weird characters.
It turned out that i need to re-encode gb2312 to ut8 in php before inserting to database. The reason when it’s working fine via phpmyadmin, it’s because when we copy & paste, the browser already re-encode from gb2312 to utf8.
here is the function i use:
$text= mb_convert_encoding($text, “UTF-8″,”gb2312”);