零宽连接符 (ZWJ)
U+200D,请求相邻字符连接,是表情符号序列的关键(👩+ZWJ+💻=👩💻),在印度文字中请求形成连字,也可用于隐藏文本边界。
What is ZWJ (Zero Width Joiner)?
ZWJ stands for Zero Width Joiner, encoded at U+200D. It is an invisible Unicode character with no visual representation of its own. Its purpose is to join adjacent characters in a way that signals to rendering software: "treat these as a combined unit." ZWJ has zero width — it takes up no space in the rendered output — but it influences how surrounding characters are shaped, ligated, or combined into a single graphical form.
ZWJ is used in two distinct but related contexts: script ligature control in complex scripts, and emoji sequence formation in modern Unicode.
ZWJ in Script Ligatures
In scripts like Arabic, Devanagari, and Sinhala, characters change shape depending on their position in a word and their neighboring characters. ZWJ instructs the rendering engine to use the "joining" or "connected" form of a character even when the natural context would produce a non-joining form.
For example, in Arabic, the letter ـه (ha in final form) would normally appear in isolated form at the end of a word. Inserting a ZWJ before it signals that it should render in its connected form, as if it were still attached to the next character in a ligature.
ZWJ in Emoji Sequences
In modern Unicode, ZWJ is best known as the mechanism for creating emoji ZWJ sequences — composite emoji formed by joining multiple base emoji with ZWJ characters between them. When a rendering platform supports the sequence, it displays a single combined image. When it does not, it falls back to displaying the individual emoji separately.
Well-known ZWJ sequences include:
- Family emoji —
👨👩👧👦is encoded as: MAN + ZWJ + WOMAN + ZWJ + GIRL + ZWJ + BOY (U+1F468 U+200D U+1F469 U+200D U+1F467 U+200D U+1F466) - Profession emoji —
👨💻is MAN + ZWJ + LAPTOP (U+1F468 U+200D U+1F4BB) - Gendered roles —
👮♀️is POLICE OFFICER + ZWJ + FEMALE SIGN + VARIATION SELECTOR - Rainbow flag —
🏳️🌈is WHITE FLAG + VARIATION SELECTOR + ZWJ + RAINBOW
The number of possible ZWJ sequences grows with each Unicode release as new combinations are approved by the Unicode Emoji Subcommittee.
ZWJ and Grapheme Clusters
Unicode defines the concept of a grapheme cluster — the user-perceived unit of text, what a user thinks of as "one character." ZWJ sequences form an extended grapheme cluster that counts as a single unit for cursor movement, text selection, and deletion. Pressing backspace on a ZWJ sequence like 👨💻 deletes the entire combined emoji, not just the final code point.
This has implications for string processing in programming languages. In Python, len("👨💻") returns 3 (three code points: man, ZWJ, laptop), but the user-visible length is 1. Proper grapheme-cluster-aware libraries are needed for accurate text metrics.
ZWJ as an Invisible Character (Security Note)
Because ZWJ is invisible and zero-width, it can be used to insert hidden content into text strings. Two strings that look identical to a human reader may have different ZWJ placements and therefore differ when compared byte-for-byte. This has been used in digital watermarking (to tag documents with invisible identifiers) and, maliciously, to bypass string-matching filters.
Quick Facts
| Property | Value |
|---|---|
| Code point | U+200D |
| Name | ZERO WIDTH JOINER |
| Unicode category | Cf (Format character) |
| Visual width | Zero — completely invisible |
| Primary modern use | Emoji ZWJ sequences |
| Script use | Arabic, Devanagari, Sinhala ligature control |
| Grapheme cluster | ZWJ sequences form a single extended grapheme cluster |
| Introduced | Unicode 1.1 (1993) |
相关术语
安全 中的更多内容
Exploiting Unicode bidirectional control characters to disguise malicious code or filenames. The …
在域名中使用视觉上相似的Unicode字符来冒充合法网站的攻击,аpple.com(西里尔а)看起来像apple.com,浏览器通过Punycode显示规则加以防范。
Exploiting Unicode normalization to bypass security filters. Input validated before normalization may …
利用Unicode功能欺骗用户:同形字用于假冒域名,双向覆盖用于伪造文件扩展名,不可见字符用于隐藏文本。
利用Unicode双向覆盖字符(U+202A–U+202E、U+2066–U+2069)伪装恶意文件名或代码的攻击,'readmefdp.exe'显示为'readmeexe.pdf'。
来自不同文字系统但外观相同或非常相似的字符,如拉丁'a'与西里尔'а',用于网络钓鱼、欺骗和社会工程学攻击。
Unicode对视觉上可能混淆的字符对的官方术语,定义于confusables.txt(UCD),比同形字范围更广,包含仅仅相似而非完全相同的字符。
识别混合不同文字系统字符的文本(如拉丁文+西里尔文),是防御同形字攻击的主要手段,浏览器据此触发Punycode显示。
U+200C,阻止相邻字符连接,在波斯语/阿拉伯语中对正确字母形式是必需的,也用于梵文中阻止连字。