อักขระความกว้างเป็นศูนย์
อักขระที่มีความกว้างศูนย์ ไม่ปรากฏเมื่อเรนเดอร์แต่ส่งผลต่อพฤติกรรมของข้อความ ได้แก่ ZWSP (ตัวแบ่งคำ) ZWJ (ตัวเชื่อม) ZWNJ (ป้องกันการเชื่อม) และ WJ (ป้องกันการแบ่ง)
What is a Zero-Width Character?
A zero-width character is a Unicode character that occupies no visual space when rendered — it is invisible, produces no glyph, and has zero advance width. Despite being invisible, zero-width characters have important semantic functions: they control how text is broken, joined, or displayed. They are essential for correct rendering of Arabic, Hebrew, Indic scripts, and for controlling ligature formation across all scripts.
The three most important zero-width characters are the Zero-Width Joiner (ZWJ), Zero-Width Non-Joiner (ZWNJ), and Zero-Width Space (ZWSP).
The Main Zero-Width Characters
| Character | Unicode | Name | Purpose |
|---|---|---|---|
| ZWJ | U+200D | Zero Width Joiner | Forces joining/ligature between adjacent characters |
| ZWNJ | U+200C | Zero Width Non-Joiner | Prevents joining/ligature between adjacent characters |
| ZWSP | U+200B | Zero Width Space | Allows line break without visible space |
| WJ | U+2060 | Word Joiner | Prevents line break (like NBSP but zero-width) |
| SHY | U+00AD | Soft Hyphen | Invisible hyphenation hint; shows hyphen only if line breaks there |
| BOM | U+FEFF | Byte Order Mark / ZWNBSP | File encoding marker; zero-width non-break space in older usage |
Zero Width Joiner (ZWJ)
The ZWJ (U+200D) tells the text shaping engine to use a joined or ligature form between the surrounding characters, even when they would not normally join.
The most famous modern use is emoji sequences. Many complex emoji are encoded as sequences of simpler emoji joined by ZWJ:
| Sequence | Result |
|---|---|
| 👨 + ZWJ + 💻 | 👨💻 (man technologist) |
| 👩 + ZWJ + ❤️ + ZWJ + 👩 | 👩❤️👩 (couple with heart) |
| 🏳️ + ZWJ + 🌈 | 🏳️🌈 (rainbow flag) |
In Arabic, ZWJ can force a letter into its final-form shape even at mid-word, and in Indic scripts it controls how consonant clusters are rendered.
Zero Width Non-Joiner (ZWNJ)
The ZWNJ (U+200C) has the opposite effect: it breaks joining that would otherwise occur. In Arabic and Persian script, letters normally join to form cursive words — but ZWNJ between two letters prevents them from connecting, showing each in its isolated form. In Indic scripts, ZWNJ prevents conjunct consonant formation.
Example: In Persian, the word "میروم" (I go) uses a ZWNJ after "می" to keep it visually separate from "روم" while still being one word (no space, but no joining).
Zero Width Space (ZWSP)
The ZWSP (U+200B) is invisible and zero-width, but it marks a position where a line break is permitted. It is used in scripts that don't use spaces to separate words — such as Thai, Lao, Khmer, and Tibetan — to give the text renderer a hint about where to break long lines.
It is also used in URLs and long technical strings in HTML to allow wrapping without adding a visible space.
Security Concerns
Zero-width characters are invisible, which makes them exploitable: - Text spoofing: inserting ZWJ/ZWNJ into usernames to create visually identical but technically different strings - Hidden watermarks: embedding patterns of zero-width characters as steganographic markers - Homograph attacks: combined with lookalike characters
Sanitize user input by stripping unexpected zero-width characters from identifiers and URLs.
Quick Facts
| Property | Value |
|---|---|
| Zero Width Joiner | U+200D — forces joining/ligature |
| Zero Width Non-Joiner | U+200C — prevents joining |
| Zero Width Space | U+200B — invisible line-break opportunity |
| Word Joiner | U+2060 — prevents line break (zero-width) |
| Soft Hyphen | U+00AD — visible only when line breaks there |
| ZWJ in emoji | Used in 1,000+ multi-person and multi-component emoji |
| Security risk | Can create invisible text or spoofed identifiers |
| Detection in Python | '\u200d' in text or regex [\u200b-\u200d\ufeff] |
คำศัพท์ที่เกี่ยวข้อง
เพิ่มเติมใน การออกแบบตัวอักษร
CSS @font-face descriptor specifying which Unicode code points a font should cover. …
Em: ความกว้างเท่ากับขนาดฟอนต์ En: ครึ่งหนึ่งของ em ใช้กำหนดความกว้างของ em dash, em space, en space …
The mechanism by which a rendering engine substitutes glyphs from a secondary …
Modern font format developed by Microsoft and Adobe supporting up to 65,535 …
ทิศทางของข้อความที่อักขระไหลจากขวาไปซ้าย ใช้กับภาษาอาหรับ ฮีบรู Thaana และอักษรอื่นๆ ต้องใช้อัลกอริทึม Bidirectional เพื่อแสดงผลอย่างถูกต้อง
Fonts downloaded by the browser to render text, declared via CSS @font-face. …
การปรับระยะห่างระหว่างคู่อักขระเฉพาะเพื่อความสวยงามทางสายตา (เช่น AV, To, LT) เป็นคุณสมบัติของฟอนต์ ไม่ใช่แนวคิด Unicode แต่มีผลต่อการแสดงผลข้อความ Unicode
U+2026 HORIZONTAL ELLIPSIS (…) อักขระเดี่ยวที่แทนที่จุดสามจุด ถูกต้องตามหลักการพิมพ์และนับเป็น 1 อักขระแทนที่จะเป็น 3
U+00A0 ช่องว่างที่ป้องกันการขึ้นบรรทัดใหม่ที่ตำแหน่งนั้น HTML: ใช้ระหว่างตัวเลขและหน่วย (100 km) ในชื่อเฉพาะ (Mr. Smith) และหลังคำย่อ
รูปแบบตัวพิมพ์ใหญ่ที่มีความสูงเท่ากับตัวพิมพ์เล็ก CSS: font-variant: small-caps Unicode ยังมีตัวอักษรพิมพ์ใหญ่ขนาดเล็กจริงใน Latin Extended (ᴀ–ᴢ)