Quantcast
Viewing all articles
Browse latest Browse all 4351

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:

Image may be NSFW.
Clik here to view.
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:

Image may be NSFW.
Clik here to view.
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.


Viewing all articles
Browse latest Browse all 4351

Trending Articles