How to insert Emoji (UTF8 4 Byte characters) into MySQL < 5.5

谁都会走 提交于 2019-12-21 18:25:12

问题


I have a website that connects with iPhone and Android users. They sometimes use UTF8MB4 characters (Emoji). When inserting those characters in strings in my MySQL database (formatted UTF8) the data was cropped at the first emoji.

Unfortunately, my hoster is running MySQL 5.1.66 and is not planning to update to a newer version yet. So what is the best solution for temporary use without switching the encoding?


回答1:


I have searched the web for many hours and I came to this solution which I want to share for other people:

Use BLOB instead of text/varchar in the database fields. Like this, you can continue to use the database tables as you did before and the Emojis are shown properly. As soon as the hoster updates the MySQL version, I will continue with using UTF8MB4 as encoding.



来源:https://stackoverflow.com/questions/18726423/how-to-insert-emoji-utf8-4-byte-characters-into-mysql-5-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!