Saving 4-byte emojis to database

In adapting a twitter feed plugin to my needs, I came across a weird problem where transients wouldn’t save, and worse, it was intermittent. I at last isolated the problem to emojis, and found this post on the subject which explained the problem.

The short version is that utf8_general_ci columns in MySQL won’t accept 4-byte characters. So one option is to convert to utf8mb4_general_ci, or alternatively as I did, to allow for any kind of server set-up, you can use the handy function wp_encode_emoji().

Time for an emoji then…

🙂

Leave a Reply

Your email address will not be published. Required fields are marked *