’ Strange Characters in WordPress posts

After upgrading, restoring a database or moving a WordPress site, you may encounter strange characters in your WordPress posts text. It appears to be a character set or charset encoding problem where apostrophes, hyphens, quotation marks and dashes appear in posts and pages as strange characters like ’‚?. The symptoms are obvious. WordPress posts and pages suddenly contain garbled, weird, or strange characters.

This problem can quickly become quite frustrating. Sometimes rendering a site nearly unreadable. Before reverting back to an earlier version or reinstalling your database, read ahead.

WordPress database character set and coalition problem

As it turns out, starting way back with WordPress version 2.2, the WordPress team added a nice new option. The ability to define WordPress database character set and coalition values within the wp-config.php file. Consequently, these defines now set the database character set to utf8 by default.

For people installing WordPress for the first time, these default defines are fine. However, if the previous WordPress database was not explicitly set as a Unicode UTF-8 charset collation to begin with (usually latin1), these new default defines can pose problems. For example, let's say my default database charset is Latin1. If a UTF-8 define is now forced, my post text would be incorrectly decoded. As a result the text would not render correctly.

How to fix the strange characters in WordPress posts

  1. Access your WordPress directory via ftp
  2. Locate and open the WordPress wp-config.php file. Find and delete the following two lines;
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
  3. Save your changes and go view your site

If all went well, you can get back to writing properly decoded content! :)