TaskRabbit is Hiring!

We’re a tight-knit team that’s passionate about building a solution that helps people by maximizing their time, talent and skills. We are actively hiring for our Engineering and Design teams. Click To Learn more

Pablo Jairala

Emojis break MySQL with UTF-8 encoding

@ 14 Feb 2014

mysql database

We’ve been running into some Tasks that have emojis as part of their descriptions, which turns out is very problematic for our UTF-8 MySQL databases.

Evan started looking for a solution and found the answer is in using the UTF8MB4 encoding. Sadly, this encoding is not entirely supported by Rails 3.

After a bit of thinking, we decided that for now the best approach would be to write a little initializer that rescues from the specific exception that’s raised when you try to save a text with emoji and replace the offending characters with blank spaces. It kinda sucks, but till proper support is introduced for Rails 3, we saw no way around it.

For the benefit of having an easy-to-reuse piece of code, we’ve abstracted that initializer into a gem called demoji. The code is pretty straighforward. You can check it out on the project’s github page!


Coments Loading...