Accommodating Dave's Emojis

Peter Rukavina

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.

Comments

Add new comment

Plain text

  • Allowed HTML tags: <b> <i> <em> <strong> <blockquote> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

About This Blog

Photo of Peter RukavinaI am . I am a writer, letterpress printer, and a curious person.

To learn more about me, read my /nowlook at my bio, listen to audio I’ve posted, read presentations and speeches I’ve written, or get in touch (peter@rukavina.net is the quickest way). 

You can subscribe to an RSS feed of posts, an RSS feed of comments, or a podcast RSS feed that just contains audio posts. You can also receive a daily digests of posts by email.

Search