Support » Fixing WordPress » Strange characters in past posts

  • Resolved Jesse Petersen


    If this is the wrong place for this, I apologize.

    I’ve been using WordPress backend since 2005 and started noticing some strange character corruptions recently.

    It seems to be changing ‘ and ” characters into things like ’ and â in my older posts and comments.

    I’ve googled and done searches and can’t find the problem because it translates that string as the letter A.

    Let me try to make sure you can see it. ’

Viewing 12 replies - 1 through 12 (of 12 total)
  • A link with an example is always helpful.
    Did you ever move your WP install from one server to another?
    Did it happen that you had to restore your blog from a DB backup?
    Did your host upgrade/change the MySQL version recently (or some time since you are blogging)?

    Those error are typical when content is moved from an older MySQL version.

    Thread Starter Jesse Petersen


    I did do a server migration around December 1. What character was the plain â supposed to be? It just appears at the end of random words.

    As I see it, most of the faulty characters appear in copy/pasted texts! Which means the original wasn’t utf-8.

    You may try to add this after line 43 in wp-includes/wp-db./php:
    mysql_query("SET NAMES utf8"); – and see if it works.

    Also search and see this thread about converting mysql:

    Thread Starter Jesse Petersen


    It didn’t work yet, but I’ll look at that thread and covert my old ones knowing that it was a conversion thing. As long as it doesn’t keep happening, I’m fine with it.

    Thanks, Moshu.

    I just did a delete and then total clean install of version 2.2 and got all those ascii replacements throughout most posts which used many different kinds of punctuation.
    It did not matter what theme. I upgraded another blog a few hours earlier and no problems. However…

    This time I had USED THE BRAND-NEW CONFIG.PHP FILE (first new one I’ve ever seen and I almost didn’t look at it).

    As soon as I read another thread supposedly resolved, I READ THIS LINE he had mentioned there:

    Or any other editor, which supports UTF-8,

    and remembered seeing that line on the New config.php file.

    I deleted the new and put back in the old and everything was perfect again. This is the first ever problem I’ve had with a WordPress install (script-wise) in about 40 installs and upgrades since May 2004.


    Resolved by using old config.php file without what I’ve bolded below.

    // ** MySQL settings ** //
    define(‘WP_CACHE’, true); //Added by WP-Cache Manager
    define(‘DB_NAME’, ‘account_name’); // The name of the database
    define(‘DB_USER’, ‘account_user’); // Your MySQL username
    define(‘DB_PASSWORD’, ‘secretword’); // …and password
    define(‘DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value
    define(‘DB_CHARSET’, ‘utf8’);
    define(‘DB_COLLATE’, ”);

    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-content/languages.
    // For example, install to wp-content/languages and set WPLANG to ‘de’
    // to enable German language support.
    define (‘WPLANG’, ”);

    /* That’s all, stop editing! Happy blogging. */

    define(‘ABSPATH’, dirname(__FILE__).’/’);

    This fix works on Pages only.

    With Posts, the problem only appears to go away. But links to posts no longer work (page not found error).
    And WordPress reports this on every non-Page page:
    Warning: Invalid argument supplied for foreach() in …wp-includes/classes.php on line 88

    I have just moved to WP 2.2 and these characters are everywhere. All the curly single and double quotes, ellipses, n and m dashes, bullets, and double byte (Chinese, Arabic, etc) characters are now utter gibberish.

    Manually removing these characters from the DB is out of the question given the volume of material. It is not a matter of search and replace given there are double byte characters present. Aaargh!!!

    Nobody ever reads the upgrade instructions… 🙁

    If you upgrade do NOT use the new wp-config file, and if you did – go back and delete the two lines:

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

    Note. Upgrading by fantastico will put those two lines in the file, so go and edit it.

    I have 2.0.2 and did not have
    define(‘DB_CHARSET’, ‘utf8’);
    define(‘DB_COLLATE’, ”);
    in my wp-config.php file.

    Any clues?

    Then why are you posting here?
    BTW, I answered your other topic:

    Thanks Moshu. All fixed now.
    I upgraded via Fantastico in CPanel. (Yes, I should have read the upgrade notes before pressing Upgrade…)

    There were two issues that affected my upgrade. Here’s a summary for future ref. The two problems may or may not be directly related. I found the fixes separately.

    1. Upgrading to WP2.2 caused funny characters to appear.

    FIX: Commenting these two lines out in wp-config.php fixed it.
    // define(‘DB_CHARSET’, ‘utf8’);
    // define(‘DB_COLLATE’, ”);

    2. WP2.2 links to single posts from archive pages (or blog home page or search page) fails because of the presence of double byte characters in posts.

    FIX: In the admin pages, I went to Options/Permalinks and re-saved the page.

    I was having the same problem and so I commented out the 2 lines in the config.php file as suggested above.

    It fixed the ’ and â characters, but now there seems to be a bunch of unwanted ?? (question marks) all over the place.

    An example can be seen here, just look at the first paragraph in the post.

    Any ideas. WP version is 2.2

    THANK YOU ZERN! Your fix helped me immensely.
    Many many thanks for making the fix simple, clear, and easy to understand.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Strange characters in past posts’ is closed to new replies.