10

Typecho博客支持emoji表情设置

 3 years ago
source link: https://www.joynop.com/p/407.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  • 大家在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并执行。

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;

0002.png

如果有别的表,比如友情链接插件,它就会创建一个 links 表,这里的话也是建议一起改了。
另外,如果安装时改过前缀,也只需对以上语句做相应修改。

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

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK