Recently I changed my hosting provider, and after switching my hosting account I started seeing wired characters on my wordpress blog. This problem is causing because we have some issue with Database Character Sets in wordpress. If you are facing similar issue, then here is solution for you.

As soon as I see this issue I didn’t get scared first, because my blog is still not yet moved completely and I’m just testing my blog on my new server before moving it. After doing a quick search on Google I noticed that many of them are having this issue and I thought I could easily fix this issue at first.

But when I started fixing this special character problem on wordpress, I noticed that most of the blog post which is published didn’t provided a clear step by step instruction to fix this issue. And I couldn’t be able to fix that issue in most cases because of incomplete guide or complicated guide. So here is a complete guide to fixing special character problem in wordpress.

What this Special/Wired Character Problem?

If you are seeing some special characters as mentioned below in your wordpress blog post after moving or changing server, then that is the same issue I’m addressing in this blog post.

     â€™    â€œ     â€   â€¦     â€“     â€”    â€’    âˆš      â„¯x      Ï€      â„¯       Ã·       â€˜

 Why Special Characters Appearing on WordPress Blog?

Before we start fixing this issue, lets know the reason behind this issue. You are seeing wired characters on wordpress blog because there is Character Sets problem in your database.

Up to WordPress Version 2.1.3, most WordPress databases were created using the latin1 character set and the latin1_swedish_ci collation.

Beginning with Version 2.2, both the database character set and the collation are defined in the wp-config.php file. Setting the DB_CHARSET and DB_COLLATE values in wp-config.php causes WordPress to create the database with the appropriate charset settings. And now the default character set in wordpress is utf8 or utf8_general_ci.

So the difference in the character set in database is causing this wired characters problem in wordpress blog.

Now you know the reason behind the special character problem in wordpress, it’s time to fix that issue.

Note: All the below steps are performed with proper backup and tested on dummy site before performing on live site. Please take backup before attempting any of these steps.

Easy Solution to Fix Wired Character Problem in WordPress:

As you know that latest wordpress defined DB_CHARSET and DB_COLLATE values in wp-config.php. Which is actually the main reason behind this issue. To fix this issue just comment those two line in wp-config.php file.

1. Open wp-config.php file and locate below lines

/** Database Charset to use in creating database tables. */
define(‘DB_CHARSET’, ‘utf8’);

/** The Database Collate type. Don’t change this if in doubt. */
define(‘DB_COLLATE’, ”);

2. Comment bold lines and Save that file. After commenting it should look like

comment db-charset in wp-config.php

Now see your wordpress blog. It should have fixed that problem.

But I don’t think this is a right way to fix the problem. So Instead of modifying wp-config.php file, lets try converting data base itself.

Converting WordPress Database to utf8 or utf8_general_ci character set

The solution to fix this character encoding problem in wordpress is, we need convert our MySQL database to utf8 or utf8_general_ci character set.

After I know the fix, I tried many guides to convert the database, but I didn’t get success because of difficulty or incomplete guides. So I left searching after wasting few hours of search to convert database to utf8.

You can view the official guide to converting database at http://codex.wordpress.org/Converting_Database_Character_Sets. But it also involves difficult process, so I left that process after trying few queries.

Now I noticed one wordpress plugin called Convert WP Database to UTF-8. Which is very old plugin, designed to convert WordPress database (both tables and columns) to UTF-8 character set.

I tried that plugin to convert database to utf8, but I didn’t get success with this plugin too. I think it’s already outdated and no longer works.

Now I discovered one more plugin called Search & Replace plugin. What this plugin do is, it searches the specific term in database and replace it with another term. Now I started trying this plugin to fix my problem, and you know what happen? it actually fixed my problem.

But I am not sure this plugin actually converts our database, but it definitely fix our wired character problem better than the easy solution which I mentioned in this post.

How I Fixed Special Character Problem using Search and Replace Plugin

1. First install search and replace plugin.

2. After installing that plugin, go to Tools >> Search & Replace

3. In Search in option, check all those option by clicking All option which is available below

search and replace wordpress plugin

 

4. In Search for enter the wired character and in Replaced with enter the value which you need to replace and click Go>> button to replace all the wired character in wordpress with proper character

replacing wired character in wordpress

 

That’s it. Now your wordpress will no longer contains any character encoding problem or wired characters.

Tip:

Before going to step 4, it’s better to collect all the wired character with right character in one place. In my case below are the special character which I need to replace with right character.

Search for Replaced with
 one space
’
“
…
–
—
‒
√
ℯx ℯx
Ï€ π
ℯ
÷ ÷
‘

 

Once you finished doing, go and cross check your blog.