avatar
😵

春夏秋冬

等待着降临在这个世界的清晨 依旧深爱着

笔记

让Typecho支持emoji

Jan 20, 2018

由于Typecho默认是不支持emoji的,这也是因为编码的问题。这时,只需要将数据库的编码utf8修改为utf8mb4就好了。还有一点,utf8mb4编码只有在MySQL5.5.3以后才支持的。

如果你的博客还没搭好的话,也可以在创建数据库时排序规则使用utf8mb4,这样就可以跳过第一个步骤。

1.修改数据库编码

进入PhpMyAdmin,选择你安装Typecho的数据库。菜单栏里进入操作,找到“排序规则”,选择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.修改Typecho配置文件

在网站根目录里找到“config.inc.php”,找到这一段代码。

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

最后效果如下

??????

接着就可以愉快的使用emoji来写文章或者评论啦!

💬 Comment

Nothing

© 2016-2024 春夏秋冬