让Typecho支持emoji

emoji.png

记得上次写了一篇文章,里面无意中输入了几个emoji,兴高采烈的点击了发布文章。没想到,洋洋洒洒几百字,最后只落得只剩半篇😭,后来发现原来是emoji出的鬼!

无奈,凭着刚才的记忆,又简单的补了一下就睡觉去了。但是,一直是我的一个心结,毕竟GitHub👨🏼‍💻都支持了,咱这也得跟进啊!

查了一下,原来是字符集的事:Typecho用的是UTF-8的编码,在 MySQL 中,UTF-8只支持最多 3 个字节,而 emoji 是 4 个字节!

网上查了下,也是有解决办法的

修改数据库

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;

修改 Typecho 配置文件

$db->addServer(array (
    'host'      =>  localhost,
    'user'      =>  'xxx',
    'password'  =>  'xxx',
    'charset'   =>  'utf8mb4', //只修改这一行
    'port'      =>  xxx,
    'database'  =>  'xxx'
), Typecho_Db::READ | Typecho_Db::WRITE);

OK,再看看博客,已经加上表情啦😘😘😘。对了,如果设备不支持,就只显示一个框框了,那就没办法了。

🍏 🍎 🍐 🍊 🍌 🍉 🍇 🍓 🍈 🍒 🍑

常见的 emoji 网站:

已有 3 条评论

  1. 回复

    Good day,

    I was digging around for information on your website today and came across your resource page.

    This is a fantastic list of resources. I didn’t even know about some of them.

    If you’re interested, I have a similar tool https://emojicut.com/.

    It might make a great addition to your page.

    Either way, keep up the great work! Thanks for your time.

    1. 王叨叨 王叨叨 [作者]
      回复

      very good!

添加新评论