Sunday 25 September 2016
php - MySQL Chinese pinyin encoding issue
Answer
Answer
I have a MySQL database set to utf8. My charset/collation variables are:
Variable_name | Value
character_set_client | utf8
character_set_connection | utf8
character_set_database | utf8
character_set_filesystem | binary
character_set_results | utf8
character_set_server | latin1
character_set_system | utf8
collation_connection | utf8_general_ci
collation_database | utf8_general_ci
collation_server | latin1_swedish_ci
I have a web page that displays Chinese characters and Pinyin from our MySQL DB. The Chinese characters display fine, but the Pinyin is garbled. For instance,
displays: Nánjīng
correct: Nánjīng
Now, I check page encoding and it is set to UTF8. I echoed out Nánjīng in PHP and it displayed fine. I checked out the data in command line and it is correct in the database. However, whenever it is coming through a query, it garbles the pinyin, but not the Chinese characters. Anyone know why this could be happening?
Answer
I figured it out. It was a collating issue. I modified the cnf to set the collation_server variable to utf8_general_ci, then reimported my data and it works fine... I don't know why I didn't think of that earlier.
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
A fair amount of the second act of The Dark Knight Rises has a class warfare plotline. This is foreshadowed in the trailers with Selina Ky...
-
I want to create an options array from a string. How can i create an array as { width : 100, height : 200 } from a string ...
-
I'm still trying to wrap my head around how the following expression results in undefined behavior: a = a++; Upon searching SO...
No comments:
Post a Comment