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!