Solution for Special Characters Causing WordPress Visual Editor to Drop Content on Save

After installing WordPress on my new server I was having trouble with the visual editor. Whenever I used a character that required a special html representation, an apostrophe (’) or quotes (“) for example, the visual editor would, on the first save, convert the symbol to it’s html equivalent in the background. (The code behind the quote character, for example, became ”. ) Then, on the subsequent save, the visual editor apparently couldn’t read the code behind the character and simply deleted it along with everything in the post that came after it. Saving posts became a nightmare.

All the literature I could find about this said it was a database character encoding issue. My database, though, was properly set up, encoded in utf8-general-ci. My WordPress config.php file matched, specifying utf–8. Still, the visual editor would delete any special characters along with everything in the post following the first special character occurrence.

I began to suspect something was the matter with the php (the coding language WordPress is written in) set up on my server. After playing around with php settings for a couple weeks I found the answer.

My php settings had multibyte string enabled. Multibyte string is a php setting that tells php how to handle characters in Japanese and other languages that have more characters than can be represented by a single byte of data. Apparently, php was trying to process those special characters as if they were Japanese, inserting the results back into the database that was set up for single byte characters, utf–8. Tilt!

Disabling the multibyte string did the trick, and now my WordPress visual editor is saving my apostrophes and quotation marks just fine, along with all the other characters in the extended utf–8 world. Just don’t try to comment on this post in Japanese!

EDIT April 24, 2014: I’ve since figured out that multibyte string itself is not the culprit. But there are several other settings to do with multibyte string you might check. For more, see here. Thanks, Conor, for the nudge to publish the  better fix!

4 comments on “Solution for Special Characters Causing WordPress Visual Editor to Drop Content on Save”:

  1. Hi Caspar,

    Thanks for your post. I’m a victim of the same frustrating issue! I’ll spend lots of time writing a post, then it simply disappears! I checked both myPHPadmin, and the wp-config.php file, and they both specify utf8, so I think the problem is within the multibyte string, as you mentioned.

    Can you go into some more detail as to how you disabled the multibyte string? What file did you need to edit/modify to make this fix?

    I’ve been pulling my hair out whenever this happens, so any tips you can provide would be greatly appreciated!

      1. Caspar, you’re a genius! Apparently the multibyte string was set to Japanese. One quick fix, and bada bing, bada boom, I can finally use all the grammatical symbols one can fathom.

        Thank you!

Comments are closed.