How to insert Emoji (UTF8 4 byte characters) in MySQL <5.5

I have a website that connects with iPhone and Android users. They sometimes use UTF8MB4 characters (Emoji). When pasting these characters into the rows of my MySQL database (formatted UTF8), the data was truncated at the first emoji.

Unfortunately, my host is running MySQL 5.1.66 and has no plans to upgrade to a newer version. So what is the best solution for temporary use without switching encodings?

+4
source share
1 answer

I searched the Internet for many hours, and I came to this solution that I want to share with other people:

Use a BLOB instead of text / varchar in the database fields. This way you can continue to use the database tables as before, and Emojis displays correctly. As soon as the host server updates the version of MySQL, I will continue to use UTF8MB4 as the encoding.

+15
source

Source: https://habr.com/ru/post/1501538/


All Articles