Why is wordpress removing some unicode characters (e.g. some emojis) when I save my post?

Try making a new post, pasting this string of emojis: “🐻🐝🐦🐈🐔🐄🦀🐕🐬🐘🐟🐸🐐🐎🐒🐼🐖🐑🐟🐢🐳” and then saving that post as a draft. When I do this (in WP version 4.7.4), it removes the emojis.

First I create the post:


enter image description here

After clicking “Save Draft”:


enter image description here

The culprit here seems to be the crab emoji:🦀 If you take it out the the emoji string everything works fine. I’m guessing this is a bug where wordpress isn’t handling new emojis properly? Can anyone help me disable the “sanitisation” that’s causing this (if it’s safe)?

It’s strange that wordpress removes all the emojis when the crab emoji is present. I think it’s got to do with the 2015 unicode 8.0 update because I tested it with the scorpion emoji which also came with that update and it causes the same problem.

P.S. I wasn’t sure on the correct tags, please let me know if there are more appropriate ones.

Edit: Note that this isn’t a rendering problem since the characters are actually gone (not just invisible or something) – they’ve been filtered out at some point in the save process.

1 Answer
1

You need to upgrade your database and table charsets to utf8mb4 (WordPress 4.2+’s default). I’ll not provide instructions as to how to do this beyond “backup first and diff and compare pre and post database dumps!” Set aside enough time to recover from any trouble.

I had the exact same problems as you, and fixed it by upgrading to a database charset that actually supports 4-bit emojis.

Leave a Comment