I had the quircky idea to display foreign languages on my blog. For me, that was Japanese. At first I thought everything was ok, and I could just input the foreign language and get away with it. No such thing! There’s lots of things that need to checked and set before your database is able to receive and save the foreign characters in the right way.
There’s two requirements if you want to have a blog that displays anything outside the latin characters in the correct way.
1. Your database connection mode, database itself, tables and fields all need to be set to the character set utf8_general_ci.
2. Your application has to support utf8 and interpret information coming from the database as utf8. Reversed, it needs to send the characters to the database as utf8.
If you use PHPMyAdmin you can find the first character set settings if you click home. It says MySQL Connection Collation and MySQL Character set. The connection collation needs to be set to utf8_general_ci. Now click your database name and go to actions. On this page you will find the second place where character sets are mentioned. Alter it to utf8_general_ci. Now look at your wordpress tables. Go to actions to inspect the character set of each of these tables. Then inspect and change the fields.
WordPress Backend
After all that work you thought you were done didn’t you? Wrong. Eventhough WordPress has UTF8 under it’s options in reading, you need to check the wp_config file and add these lines if they do not exist:
define(‘DB_CHARSET’, ‘utf8′);
define(‘DB_COLLATE’, ”);
Only now WordPress is able to interpret the characters of the MySQL database in a proper manner. Additionally, If you check a record in your database with foreign characters, it will now also display exactly as you typed it.
If you’re programming anything else, make sure the charset in meta is set to UTF-8, and the database connection needs SET NAMES UTF8.
Tip~!
Do not edit your SQL files randomly. You can only edit the files if you explicitely save them as utf8 again. If you don’t, the chars will be converted to scribble once more.
Warning~!
Don’t think just because your wordpress saves characters the right way, you’re in the clear. See what happens if you simulate a database crash by exporting an entry and importing it back in again.