Emoji表情随着IOS的普及和微信的支持越来越常见,比如这些比较常见的表情:⭐️ ? ✨ ⚡️ ? ?。所谓Emoji就是一种在Unicode位于\u1F601-\u1F64F区段的字符。这个显然超过了目前常用的UTF-8字符集的编码范围\u0000-\uFFFF。在 MySQL 中,UTF-8只支持最多 3 个字节,而 emoji 是 4 个字节。
Typecho默认不支持emoji表情,其实不是程序的锅,而是由于编码的问题,只需要将默认的数据库编码utf8修改为utf8mb4即可,当然别忘了,utf8mb4编码只有在PHP5.5以后才支持。
简单两步即可让typecho支持emoji
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', //修改这一行
'port' => 3306,
'database' => 'yourdatabase'
), Typecho_Db::READ | Typecho_Db::WRITE);
4.大功告成
测试一下
😂🌚🌝🙄🙃😊😱😏😃😄😭😍😘💣🔫👩👍💝💔❤🙈🙊🙉😚😜😝😔😫😇😅😀😞😪🙄😍😔😏🙄🐒🐤🐨🐨🐷🐨🐦🍞🍚🍣🍙🍣🍝