Japanese Characters not displaying right!
-
I have had difficulties with the displaying of Japanese characters in my Blog. Katakana characters and simple Kanji where fine but Hiragana and the more complex Kanji where impossible to display correctly. Actually most languages with complex (2 to 3 byte characters) had a problem.
I’ve up and down about 25 different forums on WordPress and I must say I had a difficult time finding a solution to my problem. But since I found it, I tought that someone else might get in the same possition as me and need the same kind of help as I needed. It’s kind of frustrating to read a post to the end just to find out: “OH! I finnally found the solution… Thanks!” and then the solution is not displayed.
Well here it is…
I’m running an Apache Server 2.0.54
PHP 5.0.4
MySQL 4.1.12
and WordPress 1.5.1.3The problem all originates from MySQL 4.1
Starting from version 4.1, MySQL supports different language encodings for diffenrent applications and my prblem originated from the “Client” encoding language and the “Server” encoding language.
The “Client” was set to Latin-1 encoding
The “Server” was set to UTF-8MySQL tries to translate from one language to the other when it puts the information in its Database. The problem is, my WordPress encoding already was UTF-8. So MySQL basically took UTF-8 encoded text (from WordPress) and treated it as Latin-1 encoded text and tried to convert it to UTF-8. Doing that, some characters where fine but more complex ones where not…
To solve this problem, you have to tell MySQL to treat all the stuff from WordPress as UTF-8 stuff. The way to do this is REAL simple.
First open the file: wordpress\wp-includes\wp-db.php
Find line 56, it should read as this:
$this->select($dbname);Go to the beginning of the line and punch “enter” to make it move one line down and leave a blank line on line 56.
Then place this line at line 56:
$this->query(“SET NAMES a€?utf8a€2”);Then your lines should look like this:
?????– $this->query(“SET NAMES a€?utf8a€2”);
?????— $this->select($dbname);And Voil??!, you now have a wordpress that can display and retain text in any language your computer can write in ??
One final note, your Database must be a UTF-8 Database and your WordPress encoding must be UTF-8 also. For wordpress, you can find this in Options/Reading.
Hope this helps someone else and save him or her a lot of problems!
- The topic ‘Japanese Characters not displaying right!’ is closed to new replies.