手动开启typecho对Emoji表情的支持的教程

说明:Emoji 表情就是输入法自带的表情,是一种在Unicode位于\u1F601-\u1F64F 区段的字符。这个显然超过了目前常用的UTF-8字符集的编码范围\u0000-\uFFFF。在MySQL中,UTF-8只支持最多 3 个字节,而emoji是4 个字节。

由于编码的问题Typecho默认不支持emoji 表情,而是需要我们手动将默认的数据库编码utf8修改为utf8mb4即可,当然别忘了,ut­f8mb4编码只有在PHP5.5以后才支持。下面就简单记录一下整个修改步骤:

1、修改数据库编码

进入PhpMyadmin,选择数据库,操作 -> 整理 -> 选择 utf8mb4_unicode_ci

2、修改数据库表编码

直接运行以下sql语句,进行编码转换:

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;

3、修改数据库配置文件

网站根目录数据库配置文件config.inc.php即可。

$db->addServer(array (
  'host'      =>  localhost,
  'user'      =>  'youruser',
  'password'  =>  'yourpassword',
  'charset'   =>  'utf8mb4', //修改这一行将uft8修改为utf8mb4
  'port'      =>  3306,
  'database'  =>  'yourdatabase'
), Typecho_Db::READ | Typecho_Db::WRITE);

👋 感谢您的观看!

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享