在MySQL
的shell中可以添加emoji
表情,但是使用sequelize
就不行了。
表中带???
的就是使用sequelize
插入的数据,带emoji
的是在shell中手动插入的。
sequelize
配置:
var sequelize = new Sequelize(mysql_db, mysql_user, mysql_passwd,{
host: mysql_host,
dialect: 'mysql',
dialectOptions: {
charset: "utf8mb4",
collate: "utf8mb4_unicode_ci",
supportBigNumbers: true,
bigNumberStrings: true
},
pool: {
max: 5,
min: 0,
idle: 10000
}
});
相关模块版本:
"redis": "^2.6.2",
"sequelize": "^3.24.0",
高洛峰2017-04-17 15:48:59
Thanks for the invitation.
It should be an encoding problem. node.js must use utf-8 encoding, while emoji is unicode encoding. So there will be?? appear.
It is recommended that you code and store it in the database. Then just decode it when you use it. The encoding method is base64.