介绍
- 大家在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;
如果有别的表,比如外链转内链插件,它就会创建一个 shortlinks 表,这里的话也是建议一起改了。
另外,如果安装时改过前缀,也只需对以上语句做相应修改。
配置网站
- 最后在网站根目录
config.inc.php
配置文件中找到以下代码:
'host' => localhost,
'user' => 'youruser',
'password' => 'yourpassword',
'charset' => 'utf8mb4', //将utf8修改为utf8mb4
测试一下
😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🤩 🥳 😏 😒 😞 😔 😟 😕 🙁 ☹️ 😣 😖 😫 😩 🥺 😢 😭 😤 😠 😡 🤬 🤯 😳 🥵 🥶 😱 😨 😰 😥 😓 🤗 🤔 🤭 🤫 🤥 😶 😐 😑 😬 🙄 😯 😦 😧 😮 😲 🥱 😴 🤤 😪 😵 🤐 🥴 🤢 🤮 🤧 😷 🤒 🤕 🤑 🤠 😈 👿 👹 👺 🤡 💩 👻 💀 ☠️ 👽 👾 🤖 🎃 😺 😸 😹 😻 😼 😽 🙀 😿 😾
- 推荐一个Emoji表情更新及时且比较全的网站 https://getemoji.com/ 需要哪个表情直接Copy