Mysql 带有 ascii 图标的文本的列类型

Mysql column type for text with ascii icons

我有一个文本区域 当我尝试将它插入我的 table 时,用户可以在其中插入 ascii 字符(主要是图标):

使用 utf8_general_ciutf8_unicode_ci 删除第一个 ascii 图标后的所有内容,我只剩下图标之前的任何文本

utf8mb4_general_ciutf8mb4_unicode_ci所有的ascii图标都转换为?

保存带有 ascii 图标的文本的最佳列类型是什么?我需要在插入之前转义它们吗?怎么样?

这是文本示例:

   
☎️ 041 3381 33 63
☎️ 041 3443 73 57

好的,我自己找到了答案,我也必须将连接字符集设置为 utf8mb4,在 utf8mb4_unicode_ci 列。

'db'            => [
    'driver'         => 'Pdo_Mysql',
    'database'       => 'telegram',
    'hostname'       => 'localhost',
    'driver_options' => [
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'utf8mb4\'',
    ],
    'username'       => 'root',
    'password'       => '',
],

当然还有客户端和服务器

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

来源:https://mathiasbynens.be/notes/mysql-utf8mb4