node.js - sequelize如何插入emoji表情?
迷茫
迷茫 2017-04-17 15:46:59
0
1
620

问题描述

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",
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
小葫芦

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template