I recently moved my WordPress-based site from DreamHost VPS to a Linode VPS running Debian + LEMP. After getting the site up again, I noticed many erroneous characters in posts; characters like " and - were being replaced with gibberish.

After doing some looking, it seemed clear that the issue was something related to character encoding.

I found a guide that suggested editing wp-config.php and commenting out the lines:

define('DB_CHARSET', 'utf8'); and define('DB_COLLATE', '');

I did this and it fixed the problem, but I'm wondering if that was the best way to go about it. Thank you for any advice.

  • I could be wrong here , but when I had a the same problem when moving servers it was do to saving the file in ascii instead of utf format
    – Bainternet
    Commented Mar 5, 2011 at 16:41

4 Answers 4


After spending the entire day working on this, I finally found a guide that worked perfectly:

Before that, I tried following @Rarst's information, tried exporting the database and manually cleaning it, tried the UTF-8 Sanitize Plugin with a modified version from here http://www.prelovac.com/vladimir/ultimate-solution-to-weird-utf-character-encoding-problem (which actually worked pretty well, but didn't fix all the characters. And was probably a terrible idea).

Anyway, if any of you ever encounter this problem, check out the first link I posted. The procedure was pretty simple and basically came down to replacing SET NAMES latin1 with SET NAMES utf8 after exporting the database, then making sure to import the new cleaned database explicitly as UTF8.

  • UTF8 Sanitize plugin is working for me (though the plugin is fairly old - says not updated in 2 years as of this comment wordpress.org/plugins/wp-utf8-sanitize ) fixing a database dump that was unclean.
    – artlung
    Commented Sep 3, 2014 at 21:05
  • 3
    the first link is broken
    – Duck
    Commented Apr 1, 2017 at 17:58

Here is another solution which worked for me...

just comment DB_CHARSET and DB_COLLATE in wp-config.php

//define('DB_CHARSET', 'utf8');

//define('DB_COLLATE', '');
  • 3
    Please explain why this would help.
    – kaiser
    Commented Nov 9, 2014 at 13:08
  • 3
    How is this "another solution"? The exact same thing was already noted in the question; he tried commenting out those two lines in wp-config.php and it worked, but he was wondering if there was a better solution. Your answer adds nothing.
    – Gabriel
    Commented Nov 9, 2014 at 13:28
  • Sorry I didn't read the question completely .... my mistake
    – Sabeer
    Commented Nov 10, 2014 at 4:42
  • Work like a charm !!! Commented Jan 4, 2017 at 12:21

See Converting Database Character Sets in Codex. Article has note about being completely rewritten at 3.0.1 version so info should be up to date.

  • Thanks for the answer Rarst. It was a little more extreme than I needed, I ended up just needing to replace an instance of SET NAMES latin1 with SET NAMES utf8 and re-import the database explicitly as UTF8. Commented Mar 5, 2011 at 23:18

I transitioned my website files from an old to new directory and I was able to modify:

define('DB_CHARSET', 'utf8mb4');


define('DB_CHARSET', 'utf8');

And this resolved the black diamond whitespace issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.