如何让Typecho支持emoji表情

逆风 技术分享1 281字数 2220阅读模式

介绍

关于emoji

表情符号是包含表情符号或表情符号的Unicode块。它们中的大多数都是用来表示人脸的,尽管其中一些包括手势或非人类角色(有角的“小鬼”、猴子、卡通猫)。

该块于2008年首次提出,并首次在Unicode版本6.0(2010)中实现。采用该标准的原因主要是为了与日本电话运营商于本世纪初建立的事实标准兼容,该标准使用Shift JIS标准的前导字节0xF5至0xF9编码在未使用的范围内。[6] KDDI已经走得更远了,在空间中引入了数百个前导字节0xF3和0xF4。

Emoticons is a Unicode block containing emoticons or emoji. Most of them are intended as representations of faces, although some of them include hand gestures or non-human characters (a horned "imp", monkeys, cartoon cats).

The block was first proposed in 2008, and first implemented in Unicode version 6.0 (2010). The reason for its adoption was largely for compatibility with a de facto standard that had been established by the early 2000s by Japanese telephone carriers, encoded in unused ranges with lead bytes 0xF5 to 0xF9 of the Shift JIS standard.[6] KDDI has gone much further than this, and has introduced hundreds more in the space with lead bytes 0xF3 and 0xF4.

From wikipedia

emoji在Unicode编码区中位于U+1F600至U+1F64F

如何让Typecho支持emoji表情

让Typecho支持

关于

MySQL字符编码集中有两套UTF-8编码实现:“utf8”和“utf8mb4”,其中“utf8”是一个字最多占据3字节空间的编码实现;而“utf8mb4”则是一个字最多占据4字节空间的编码实现,也就是UTF-8的完整实现。这是由于MySQL在4.1版本开始支持UTF-8编码(当时参考UTF-8草案版本为RFC 2279)时,为2003年,并且在同年9月限制了其实现的UTF-8编码的空间占用最多为3字节,而UTF-8正式形成标准化文档(RFC 3629)是其之后。限制UTF-8编码实现的编码空间占用一般被认为是考虑到数据库文件设计的兼容性和读取最优化,但实际上并没有达到目的,而且在UTF-8编码开始出现需要存入非基本多文种平面的Unicode字符(例如emoji字符)时导致无法存入(由于3字节的实现只能存入基本多文种平面内的字符)。直到2010年在5.5版本推出“utf8mb4”来代替、“utf8”重命名为“utf8mb3”并调整“utf8”为“utf8mb3”的别名,并不建议使用旧“utf8”编码,以此修正遗留问题

Typecho默认数据库编码为Utf8,所以不支持emoji

支持

首先登录PHPMyadmin

在服务器连接排序规则改为 utf8mb4_unicode_ci

如何让Typecho支持emoji表情

再选择你的数据——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;

如何让Typecho支持emoji表情

[scode type="blue" size=""]如果还有别的数据表,建议一块更改为utf8mb4

另外,如果安装时改过前缀,也只需对以上语句做相应修改。[/scode]

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

charsetutf8改为utf8mb4

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

😂🤣😊✌

转载请保留原文链接
逆风
  • 本文由 发表于 2022年1月20日 14:42:00
  • 转载请务必保留本文链接:https://blog.smallxu.com/post/419/
评论  1  访客  1
    • 匿名
      匿名 0

      🌚🌚🌚🌚哈哈

    匿名

    发表评论

    匿名网友

    :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: