Accommodating Dave’s Emojis

My friend Dave sent me a bug report tonight relating to his attempt to post a comment here that contained an emoji:

Hmm. I got this while submitting a comment. On iOS obviously. I had loaded the page without content blockers, which I seem to need to do for your comments to work.

The comment I was submitting: β€œI think I know this woman of whom you speak. πŸ˜‰β€

He attached a screen shot from his iPhone, showing the error dialog he received:

Error message on Dave's iPhone

Now, first off, this made me realize that I’d left display of detailed error messages turned on for the Drupal that runs this site; to fix that–not the source of the issue, but a good idea on a production site–I turned that off, under Development > Logging and errors.

Next, to the problem at hand: I suspected that it was Dave’s need to post a comment containing a winking face emoji (πŸ˜‰) that was the source of the error, and suddenly I realized the implication of the warning in my Drupal status report, heretofore ignored, about the lack of β€œ4 byte UTF-8” support:

4 byte UTF-8 error message

It turns out that characters like emoji are represented by 4 bytes. In the case of the winking emoji, it turns out, these 4 bytes are \xF0\x9F\x98\x89, and, indeed, if you look at the error Drupal was throwing up about Dave’s comment, you can see that being flagged as an β€œincorrect string value.”

The solution turned out to be simple: following the helpful instructions here, I converted the MySQL database for this Drupal to support 4 byte UTF-8. There were several steps to this: first I needed to add support in MySQL by editing my my.cnf file, then I had to convert the database and its tables, and finally I had to edit my settings.php to reflect the change. Once I did this, I was able to post emoji-laced comments at will.

Go wild, Dave.


Peter Rukavina's picture
Peter Rukavina on June 1, 2018 - 22:01 Permalink

Is this thing on? πŸŽ™οΈπŸ‘©β€πŸŽ€πŸŽ½

Dave Hyndman's picture
Dave Hyndman on June 2, 2018 - 09:10 Permalink

πŸ™πŸΌ πŸ‘πŸ»πŸ‘ŒπŸ»πŸ˜Ž

Bob's picture
Bob on June 2, 2018 - 09:12 Permalink


Martin's picture
Martin on June 2, 2018 - 11:43 Permalink

Excellent 🍻