emoji表情字符无法在mysql存储的问题
06 Jul 2014前几天处理emoji无法在mysql中保存的bug,
原因:
mysql中的utf-8为3bytes,emoji字符为4bytes
解决方法:
1.升级mysql,mysql version >= 5.5.3
2.MySQL-python >= 1.2.4b5
3.修改数据库或者表或者字段的charset为utf8mb4(兼容utf8,4bytes)
例:ALTER TABLE table_name MODIFY COLUMN column_name longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ;
参考链接:
http://stackoverflow.com/questions/7814293/how-to-insert-utf-8-mb4-characteremoji-in-ios5-in-mysql
http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
转载请注明:于哲的博客 » emoji表情字符无法在mysql存储的问题