- typecho的数据库类型默认不支持emoji编码,因为Emoji是一种在Unicode位于u1F601-u1F64F区段的字符。这个显然超过了目前常用的UTF-8字符集的编码范围u0000-uFFFF。
- 在MySQL中,UTF-8只支持最多3个字节,而emoji是4个字节。所以如果你不修改数据库的话,typecho是无法支持Emoji表情的。
- 当然好消息是utf8mb4其实是完全兼容utf-8,修改后,不会影响现有数据及后期的数据。
- 要注意的是utf8mb4编码在PHP5.5以后才支持,所以请确保你的PHP版本在5.5以上,typecho程序推荐PHP5.6版本。
推荐开发项目的时候mysql的编码格式设置为utf8mb4
用navicat等工具连接数据库后设置数据库字符集为:utf8mb4 排序规则为:utf8mb4_unicode_ci
并执行下列语句(注意表名要对应)
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网站的根目录的config.inc.php文件中找到并修改
'host' => localhost,
'user' => 'youruser',
'password' => 'yourpassword',
'charset' => 'utf8mb4', //将utf8修改为utf8mb4**
最后测试emoji??
1 条评论
哈哈哈,写的太好了https://www.lawjida.com/