Strange characters when migrating WordPress

This normally happens when you migrate to and bring in improperly encoded (in utf-8) to a new system using an SQL dump, you can copy and paste to-do a search and replace from here, this seems to be the 6 most common.

“    “    double open quote
”     ”    double close quote (careful there is a hidden character there)
‘    ‘    single open quote
’    ’    single close quote (curly apostrophe)
…    …    triple dot (ellipsis)
–    –    long hyphen

You can run these SQL commands to change these in bulk:

UPDATE mk_posts SET post_content = replace(post_content,’“’,”“”);
UPDATE mk_posts SET post_content = replace(post_content, /â€[[:cntrl:]]/, “””);
UPDATE mk_posts SET post_content = replace(post_content,’‘’,”‘”);
UPDATE mk_posts SET post_content = replace(post_content,’’’, “’”);
UPDATE mk_posts SET post_content = replace(post_content,’…’, “…”);
UPDATE mk_posts SET post_content = replace(post_content,’–’, “–”);

Leave a Reply

Your email address will not be published. Required fields are marked *

CISSP PMP