Clean up your WordPress database from weird characters

Encoding problems can be really painful. Instead of manually update all of your posts, here is a query that you can run in order to clean your database from weird characters.

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘“’, ‘“’);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘”’, ‘”’);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘’’, ‘’’);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘‘’, ‘‘’);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘—’, ‘–’);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘–’, ‘—’);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘•’, ‘-‘);

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘…’, ‘…’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘“’, ‘“’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘”’, ‘”’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘’’, ‘’’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘‘’, ‘‘’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘—’, ‘–’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘–’, ‘—’);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘•’, ‘-‘);

UPDATE wp_comments SET comment_content = REPLACE(comment_content, ‘…’, ‘…’);