unicode - 所有 ZWJ 序列都有效吗?
问题描述
解决方案
There are restrictions on what can be part of ZWJ sequences and what cannot. Unicode Technical Standard #51 lays out these rules.
According to definition ED-15a, a well-formed ZWJ sequence can only consist of:
- Emoji characters (a character with the property
Emoji=True
) - Emoji presentation sequences (an emoji character followed by U+FE0F VARIATION SELECTOR-16, all valid combinations of which are listed in this data file)
- Emoji modifier sequences (a character with the property
Emoji_Modifier_Base=True
followed by a character with the propertyEmoji_Modifier=True
)
All relevant properties can be found in this data file.
U+2605 BLACK STAR is not an emoji character (and it is obviously not one of those types of sequences either), so it would not be valid for use in ZWJ sequences as of the time of writing, but you could substitute U+2B50 WHITE MEDIUM STAR (which is an emoji) instead. Other than that, ️ and are fair game.
Side note on U+1F3F3 WAVING WHITE FLAG: This character is an emoji, but it has the property Emoji_Presentation=False
, which means it is intended to display as text-style (monochrome rather than colourful) by default. To force emoji-style display, U+FE0F VARIATION SELECTOR-16 has to be appended to it. It is recommended that these variation selectors always be included for characters where Emoji_Presentation=False
.
U+2B50 WHITE MEDIUM STAR is also a valid base for such emoji presentation sequences, but it has Emoji_Presentation=True
by default and the variation selector is thus entirely optional. U+1F7E9 LARGE GREEN SQUARE meanwhile is not a valid base for emoji presentation sequences and therefore must never be followed by VARIATION SELECTOR-16. I know, it’s convoluted.
What all this means is that you have two choices for the precise sequence of codepoints you want to use, both of which are equally valid. Either:
️⭐ <U+1F3F3, U+FE0F, U+200D, U+2B50, U+200D, U+1F7E9>
Or:
️⭐️ <U+1F3F3, U+FE0F, U+200D, U+2B50, U+FE0F, U+200D, U+1F7E9>
推荐阅读
- python - FuzzyWuzzy 提取物中的奇怪行为
- webpack - 没有 FOUC 的 Webpack HMR 可能吗?
- java - Spring Batch java.sql.SQLException.RowMapper 获取页数和记录数
- neo4j - Neo4j 查询与节点之间的布尔运算
- android - 广播接收器 onReceive 在位置更改时触发两次
- sql - TSQL 查询以在显示第一条完整记录后合并所有记录
- excel - VBA 或 FORMULA 用最近的工作日期更新文件路径名
- algorithm - 在 i 个目的地之间移动 n 个项目
- c# - C# 生成的 Excel 文件:文件格式或文件扩展名无效
- android - 在 DB 查询中传递特殊字符 (')