I use the powerful BackupBuddy plugin by iThemes to take a regular automated backup of all my sites. This plug-in also doubles up as a web host migration tool.  This time when I cloned one of my wordpress based sites to a staging environment, I started seeing lots of weird characters in the article like these  ⠀

Essentially the older WordPress blogs that were created before WordPress v2.3 didn’t use to specify the default character set for character encoding hence the WordPress tables were created with the default set of MySQL installation which was latin1. The wp-config file that shipped with the earlier versions didn’t have character encoding info inside it.

Post v2.3, WordPress started using the omnipresent utf-8 character encoding for the MySql installation. This conflict between character encoding turned out to be the cause for such weird characters inside my site’s articles.

While the fact finding was tough, the fix was quite simple:

Just add these two lines to the wp-config.php file present in the root directory of your wordpress installation and your site will be back to normal.

define('DB_CHARSET', 'utf8'); /* Database Charset to use in creating database tables. */
define('DB_COLLATE', ''); /* The Database Collate type. Don't change this if in doubt. */

Update Aug 2020: On one of our oldest sites that started in 2008, this issue surfaced for the first time. There were some old plugins that used latin1 encoding, even using the fix above didn’t work.  We used the latin1 character encoding, and all weird character issues were gone.

define('DB_CHARSET', 'latin1');
define('DB_COLLATE', '');

If you have little bit of interest in programming, you should definitely learn more about character encoding. Joel Spolsky, CEO of StackExchange has explained in depth about this topic. You can also learn more about character encoding in the video below

Pin It on Pinterest

Share This