Typecho支持emoji

Typecho用的是UTF-8的编码,在 MySQL 中,UTF-8只支持最多 3 个字节,而 emoji 是 4 个字节!

可以通过以下几个步骤来支持emoji

修改数据库

alter table typecho_comments convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_contents convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_fields convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_metas convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_options convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_relationships convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_users convert to character set utf8mb4 collate utf8mb4_unicode_ci;

修改 Typecho 配置文件

$db->addServer(array (
    'host'      =>  localhost,
    'user'      =>  'xxx',
    'password'  =>  'xxx',
    'charset'   =>  'utf8mb4', //只修改这一行
    'port'      =>  xxx,
    'database'  =>  'xxx'
), Typecho_Db::READ | Typecho_Db::WRITE);

已经加上表情啦 😀😁 。对了,如果设备不支持,就只显示一个框框了,那就没办法了。

请登录后发表评论

    没有回复内容