Monday, September 08, 2008

Strange characters ’ and  in Wordpress posts

After a wordpress upgrade we started to get all kinds of weird symbols in our posts, including  and ’. I figured it was a character encoding mismatch problem and a quick search on the Wordpress forums confirmed it. You have to comment out two lines in your wp-config.php file (found in your main blog directory). These are the two lines:
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

Comment them out like this:

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

Fixed our problem.

Labels: ,

30 Comments:

At 6:10 AM, Anonymous Sheilla said...

Thank you so much for the information, it worked :D Just when I thought that I had to edit the whole 500 posts in my database.

 
At 7:47 PM, Blogger Techwiz said...

No problemo!

Something else I have noticed is that Firefox's character encoding can mess things up too.

If you see some of those wild and wacky characters, try going to View > Character encoding. Choose a different character encoding than the one you have now, and see what it does to the web page. So if you are currently set to Western ISO-8859, try UTF-8 and see what happens.

 
At 2:21 PM, Anonymous Anonymous said...

Thank you so much for the info! I too thought I'd have to edit my entire blog to remove the annoying character.

 
At 6:47 AM, Blogger dfisher said...

Thank you! I upgraded to 2.7 and had already edited the last 50 posts to remove the weird characters, and then found them back again this morning. Finding this was a big relief.

 
At 3:59 PM, Blogger Mishka said...

Thanks for this, saved my butt! (or at least hours of annoyance trying to figure out what's going on) ;)

 
At 10:36 PM, Anonymous Dillon said...

Many, many thanks for this tip!

 
At 6:12 PM, Blogger John Jr. said...

Hm... I just freshly installed WordPress, started having these very same strange characters show up in posts, found this site, opened up my wp-config.php file, and found it didn't even have those lines you mentioned. How can this be?! Any tips on licking this problem would be mos appreciated!

 
At 6:16 PM, Blogger John Jr. said...

Ooops. Sorry for the follow-up post here, but I forgot to check the "Email follow-up comments to..." button. This time I did!

 
At 11:08 PM, Blogger Techwiz said...

John, Post a link to your site, so we can see the strange characters.

:-)

 
At 11:36 PM, Blogger John Jr. said...

D'oh! That was silly. Yes, here it is in action:

http://www.lasalamander.com/projectography

Of course, as I'm only just starting this site, there are only a couple entries, and I've been fixing the weird characters whenever they show up, so I don't have a lot of great examples. But they do seem to just randomly show up, so who knows. Maybe there'll be a new one by the time you look.

However, I did just spot a new one that showed up--one that I already deleted before but has come back anyway. If you look under the excerpt text of the A Random Test Post entry, you'll see it says "Filed under: 3am, 89°, no wind" That  definitely shouldn't be there.

Also, in the post Captain Chancey, when I originally posted it, the lines showed up like this:

Among his many endeavors, Joshua Wentz does a somewhat improvised music project every once in a while that he calls Winchester Sessions.Â

And somewhere else I remember the word "you'd" got turned into this: you’d

Any ideas, Techwiz? :D

 
At 9:02 PM, Blogger John Jr. said...

Well, of course, by now my previous post has become irrelevant. Not that I found a solution. It just seems to have gone away by itself.

Meanwhile, I've got a new problem which is not at all the same thing, but hey, it can't hurt to ask since I'm totally stuck on a solution:


So I'm new to theme editing but learning quickly. I was trying to figure out how to edit the widgets themselves by tweaking my widget.php file, and then something odd happened: At the top of my all of my site's pages (as well as at the top of the admin pages, somehow!!) there's this line:

it', 'widget_many_register' ); */ ?>

Okay, so my first though is that I messed up my widgets.php file, so I'll just undo the damage by replacing it with the backup copy I made in the event that something like this should happen. And so I do. But...nothing changed! That crazy bit of code is still there. In fact, on my Dashboard page it's also the first line in the Incoming Links, Plugins, Wordpress Development Blog, and Other Wordpress News windows. That's crazy! What on Earth did I do? Any clues?

Thanks!

http://lasalamander.com/blog

 
At 11:58 PM, Blogger Techwiz said...

Hi John,
Sorry I didn't get back to you sooner on the strange characters issue. I am a lazy blogger. So lazy, in fact, that I don't even read the comments on my blog.

Re: your current issue...the wiget_many_register thing is a broken bit of code. It looks like it used to be a bit of inline css style that has been commented out.

Textpad will let you search through a folder of files, use it to find your little broken bit of code. Then hopefully you will see what needs to be done. Delete it or restore it from the original file.

Let us know how it goes.

 
At 7:36 AM, Blogger John Jr. said...

Well I definitely thank you for your willingness to help, Techwiz. I'm so confounded on this issue, and I'm hoping I won't have to just go and reinstall WordPress to fix it. I did find the source of that bit of weird code. It happens to be the very last bit in the widgets.php file. So the very first thing I tried was to restore the original widgets.php file, but it changed nothing! I also went and tried deleting that particular bit of text from the file, but still, it's showing up on the site anyway. Where on earth is it coming from?!

 
At 10:12 AM, Blogger John Jr. said...

See, if you just keep on approving my comments, I'll eventually work it out on my own. That is to say, I fixed it. Or...it fixed it self. I didn't exactly find the solution, but it's all better now. All I did was upgrade WordPress to the latest version and and presto-chango, it fixed it self. Thanks for giving me a forum to post my progress. ;)

 
At 12:19 AM, Blogger Techwiz said...

I *love* this new method of tech troubleshooting. All I have to do is approve comments and problems get solved!
Upgrading, like reinstalling, is a good way to sort out a lot of technical glitches. Glad things are working now.

 
At 12:07 AM, Blogger Adriana said...

Hello. I know this is a super old post but it's the only one that I googled that gave me what I think may be an answer to my problem

I too type and it comes out in strange characters like the ones you shouw. HOWEVER, my problem is not with wordpress, but rather with blogger.

Do you happen to know how I can fix this same problem in blogger?

thanks a million!

 
At 10:28 AM, Blogger Techwiz said...

Post a link, Adriana. :-)

Does it happen to all your posts, or certain ones only.

When did it start happening?

 
At 5:10 PM, Anonymous Anonymous said...

Wow! Thanks alot! I accidental deleted my database but i recovered it. When I got it back these strange symbols were all over the place. Your advice worked perfectly!

 
At 5:13 PM, Anonymous Gil said...

Thanks for this post, it was very helpful. All my posts had those strange sybols in it. I did notice on my database view with phpmyadmin, there was a new character type property that I didn't think I has seen before. I think it must have something to do with that. Anyway, your fix worked beautifully. Thanks!!!

 
At 1:39 PM, Anonymous Anonymous said...

Your fix apparently worked for strange characters that appeared in many posts when I moved a wordpress site from one domain to another account with the same host. Tried all other suggestions, like changing table column to blog, then back to text, etc. Nothing worked until I used your fix of commenting out the two lines in the config file. Thanks.

 
At 11:21 PM, Blogger Swaddo said...

.. or you could just change ..

define('DB_CHARSET', 'utf8');

to

define('DB_CHARSET', 'utf16');

 
At 3:57 AM, Anonymous Anonymous said...

FanFlippingTastic, I was reading the other horribly techie looking posts on the wordpress forums and thinking, 'whoa, I'm going to need a lot more coffee before I attempt this lot, and then I saw the link to this fix. 30 seconds later and all is well.

Thankyou!!

 
At 6:39 PM, Blogger Joseph said...

This was mighty helpful - thanks for sharing!

 
At 11:27 AM, Blogger Cynthia K said...

Thank you. Fixed my issue in about 10 secs. Excellent.

 
At 3:34 PM, Anonymous Andrew Kronemyer said...

It worked! Thank you so much!

 
At 6:15 PM, Anonymous amanda said...

LOL ! You have no idea how much you have helped me, I too, like Sheila would have just had to manually edit 400+ posts hahahaha Thanks so so much!

 
At 7:04 AM, Blogger James Wilmans said...

I am so grateful that I cannot begin to explain, I have an e-commerce site with hundreds of posts that all freaked out with these alien symbols.
My client is now releasing the rest of his payment to me. Thank you so so much. You are a freaking Legend!

 
At 2:24 PM, Blogger Techwiz said...

I am glad that this post is still helping people! Thanks for all the nice comments everyone!

 
At 5:33 AM, Anonymous rafaelromero said...

thanks, it fixed mine!

 
At 7:40 AM, Blogger Choco said...

Thanks alot , nearly had to go through all manually!

 

Post a Comment

Links to this post:

Create a Link

<< Home