WordPress.org

Support

Support » How-To and Troubleshooting » Smart quotes and other characters converted wrongly

Smart quotes and other characters converted wrongly

  • Smart quotes, apostrophes, and other characters are showing up on my blog as “?”. Earlier they were showing up correctly, but while tyring to solve another problem, I had to back up and then re-import my database. After the rebuild the quotes became gibberish.

    Here’s the thing I can’t figure. If I go into phpMyAdmin and look directly at the database, all the information appears as it should. All the characters are correct. But the blog won’t read them that way (even though a few hours ago it would.)

    Can anyone explain what the problem could be and/or offer a solution?

Viewing 7 replies - 1 through 7 (of 7 total)
  • WPChina
    Participant

    @wordpresschina

    is there a chance your pages are encoded not in utf-8? For example, did you make a change to how your blog is displayed? Your phpMyAdmin should be displaying in utf-8, and therefore all the characters seem fine, but your blog might not be like that.

    I just posted a related (though different) problem, btw, a few moments ago.

    I went into phpMyAdmin and saw that yes, most of my tables were not listed under utf-8. (It is set to utf-8 on the wp-admin.) I changed most of them to utf-8-unicode (althought some of rows, even after I made change reverted back to latin_swedish or something. No idea why they won’t change.) But I changed the table for “post content”, cleared the cash, reloaded the blog and it basically had no effect. I also went into default_filters.php and blocked out wp_texturise on the_content. Again, no effect on the blog.

    Another wrinkle, a contributor added a new post to the blog. If I look at this post, in the database (via myphpadmin) apostrophes look like this ’, but show up properly on the blog. The exact opposite of how all the previous posts are working, where it’s correct in the database, but incorrect on the blog (usually converted to question marks.)

    Does this make sense to anyone? I’m still pretty new to WP so this database stuff confuses me.

    trying again:

    same problem persists; however I’ve been told that the quotes show up fine on a Mac.

    Again, within the database (via myPHPadmin) the smart quotes appear as smart quotes, but within WordPress, and the on the blog, they appear as ? or squares.

    It seems to be a MySQl bug.
    Even in this forum I can show you earlier posts where extended (accented) characters were used or even just quotes or apostrophes… and they look now screwed.

    Similar threads:
    http://wordpress.org/support/topic/48459?replies=6

    Try this hack:
    http://wordpress.org/support/topic/55282?replies=7#post-303707

    Thankyou,thankyou,thankyou,thankyou!!

    That hack did work. I had to rebuild my database from an older backup (since SQL had already changed some of the data permanently) but now all the quotes and apostrophes seem to be showing up as written.

    Here’s the solution is again, if anyone else needs it:

    Add the line:

    mysql_query(“SET NAMES ‘utf8′”);

    to the file /wp-includes/wp-db.php right after line 43 (after it makes the database connection, but before the “if” statement).

    WPChina
    Participant

    @wordpresschina

    Yes!! Worked for me too! 🙂

    Now, is there a way to get mysql_query(“SET NAMES ‘utf8′”); added to future releases of the software? I think this is a critical cosmetic fix for some of us on our blogs… I am unsure of the protocol at WP on how to request this–any idea to which guru I need to kowtow to in order to get this added? ;-p

    Bug and fixes should be posted here: http://trac.wordpress.org/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Smart quotes and other characters converted wrongly’ is closed to new replies.