I'm trying to move my WordPress blog from Windows to Linux, but I'm seeing a weird character encoding problem in the Linux version that I'm not seeing on Windows. (I had thought it was an issue with the way I used mysqldump to export the data, but after upgrading mysql, dumping, checking, etc., I'm pretty sure I did that part OK). The data in the database on Windows is exactly the same as it is on Linux.

Here's what apostrophe's look like on my Windows blog:

enter image description here

And here's how it appears on the Linux blog:

enter image description here

As you can see, there's a weird ΓÇÖ series of characters instead of an apostrophe. Is there a setting in WordPress that I need to change to get it to render it correctly?

More details:

Windows, I'm getting back in the response the following bytes for the single apostrophe:

E2 80 99

Linux, I'm getting back bytes for ΓÇÖ:

CE 93 C3 87 C3 96

It looks to me like you're not using an actual apostrophe, but one of the curly apostrophes, such as those that Microsoft Word might be configured to auto-correct to. There is a chance that your mysqldump was actually exporting it incorrectly. In my test database, both PowerShell and Command Prompt were dumping as ΓÇÖ, whereas Cygwin was dumping as . If your export does look fine in those areas, you may want to check the Content-Type return header to see that it is specifying UTF-8. If both of those check out, it could be that the database's encoding needs to be modified.

As an alternative, you could replace any occurrence of with '.

|improve this answer|||||
  • My apologies for the slightly vague answer, but I do not have the ability to comment everywhere yet. – Doug Aug 18 '12 at 13:56
  • vague is fine. Those are some good things to check. – Ben McCormack Aug 18 '12 at 13:58
  • Content type for both is text/html UTF-8. Looking at the source of what was returned, Windows host is returning and Linux host is returning ΓÇÖ. – Ben McCormack Aug 18 '12 at 14:03

The problem ended up being (I think) Powershell's wrangling of the output from mysqldump. In powershell, I had been using:

mysqldump -u**** -p**** -h**** wordpress --default-character-set=utf8 | 
   out-file out.sql -Encoding UTF8

I was even good about explicitly outputting UTF8 for both mysqldump and out-file! However, it seems (and this is really hard to prove because it's hard to tell what powershell does with UTF8 multi-byte unicode characters once you pass it to out-file) that out-file is having trouble handling multi-byte unicode characters in UTF8.

I switched to using the plain old Windows command prompt, which outputted data correctly:

mysqldump -u**** -p**** -h**** wordpress --default-character-set=utf8 > 
|improve this answer|||||
  • After digging in a little more, I think that it might still be mysqldump, not powershell, but the weird thing is that for some reason cmd's output works, whereas powershell's does not. – Ben McCormack Aug 21 '12 at 14:34
  • Yes but instead of correcting just the dump, how do you import the incorrectly encoded file still if that's all you have? – Mike Kormendy Dec 13 '19 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.