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

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

1.修改数据库编码

进入phpMyAdmin,选择您的数据库,操作->整理->选择utf8mb4_unicode_ci

2.修改数据库表编码

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

1
2
3
4
5
6
7
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

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

完事!😀😁😂🤣😃😄😅😆😉😊😋😎😍😘🥰😗😙😚🙂🤗🤩🤔🤨
转载自:https://www.moewah.com/archives/1635.html