介绍

  • 大家在typecho博客评论时,很多人都喜欢使用emoji表情(比如😊😜😒这些图标)但是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版本。
  • 下面开始带大家一步步的设置。

数据库编码修改

进入PhpMyadmin,选择对应的数据库,选择操作——排序规则——选择utf8mb4_unicode_ci并执行。

  • 选择SQL-复制下面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;
运行SQL.png

配置网站

  • 最后在网站根目录config.inc.php配置文件中找到以下代码:

'host' => localhost,
'user' => 'youruser',
'password' => 'yourpassword',
'charset' => 'utf8mb4', //将utf8修改为utf8mb4

  • 然后试试看吧。😀😁😂😃😄😅😆😉😊😋😎😍😘😗😙😚😇😐😑😶😏😣😥😮😯😪😫😴😌😛😜😝😒😓😔😕😲😷。。。

点赞 ({{click_count}}) 收藏 (0)