You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VS15 and VS16 from [Unicode TR51](https://unicode.org/reports/tr51/#Emoji_Variation_Sequences)
31
52
32
-
| Library |Behavior|
33
-
|---------|----------|
34
-
|**displaywidth**|Treats variation selectors as part of emoji (width 2) |
35
-
|**go-runewidth**|Treats variation selectors as separate characters (width 1 each) |
36
-
|**uniseg**|Treats variation selectors as part of emoji (width 2) |
53
+
| Library |VS16 (U+FE0F) | VS15 (U+FE0E)|
54
+
|---------|---------------|---------------|
55
+
|**displaywidth**|Forces emoji presentation (width 2)| No effect, preserves base width|
56
+
|**go-runewidth**|Treated as separate character (width 1) | Treated as separate character (width 1) |
57
+
|**uniseg**|Treated as part of emoji (width 2)| Forces width 1|
37
58
38
59
**Example:**`☺️⌛︎❤️` (3 emoji with variation selectors)
39
-
- displaywidth: 5 columns
60
+
- displaywidth: 6 columns
40
61
- go-runewidth: 4 columns
41
62
- uniseg: 5 columns
42
63
43
-
### 3. Keycap Sequences
64
+
I would appear to me (@clipperhouse) that the handling of VS15 is not widely
65
+
agreed upon. Some libraries and standards (such as wcwidth) interpret it as
66
+
"always narrow to width 1". Others (such as this library) interpret it as
67
+
"no effect on width, use the base character width".
68
+
69
+
Here is [a conversation on GitHub](https://github.com/contour-terminal/contour/discussions/1178#discussioncomment-6778716) and an [explanation from Grok](https://grok.com/share/bGVnYWN5LWNvcHk%3D_274f540c-c9a6-47c7-9d4f-47697ed20032).
Keycap sequences like 1️⃣ are formed by: base character + variation selector (U+FE0F) + combining enclosing keycap (U+20E3).
48
74
49
75
| Library | Behavior | Width per Keycap |
50
76
|---------|----------|------------------|
51
-
|**displaywidth**| Treats as single wide emoji | 2 columns |
52
-
|**go-runewidth**| Treats base character only | 1 column |
53
-
|**uniseg**| Treats as single narrow character | 1 column |
77
+
|**displaywidth**| Treats as emoji | 2 columns |
78
+
|**go-runewidth**| Treats base character | 1 column |
79
+
|**uniseg**| Treats as base character | 1 column |
54
80
55
81
**Example:**`1️⃣#️⃣` (2 keycap sequences)
56
82
- displaywidth: 4 columns (2 per keycap)
57
83
- go-runewidth: 2 columns (1 per keycap)
58
84
- uniseg: 2 columns (1 per keycap)
59
85
60
-
### 4. East Asian Ambiguous Width
86
+
## East Asian Ambiguous Width
61
87
62
-
**East Asian Ambiguous characters** (★, °, ±, etc.) can be rendered as either narrow (1 column) or wide (2 columns) depending on configuration.
88
+
[East Asian Ambiguous characters](https://www.unicode.org/reports/tr11/#Ambiguous) (★, °, ±, etc.) can be rendered as either narrow (1 column) or wide (2 columns) depending on configuration.
63
89
64
90
| Library | Default | With EastAsianWidth=true |
65
91
|---------|---------|--------------------------|
66
92
|**displaywidth**| Width 1 | Width 2 |
67
93
|**go-runewidth**| Width 1 | Width 2 |
68
-
|**uniseg**| Width 1 | Width 2 (usually) |
94
+
|**uniseg**| Width 1 | Width 2 |
69
95
70
96
**Example:**`★°±` (3 ambiguous characters)
71
97
- displaywidth default: 3 columns
@@ -75,29 +101,6 @@ Keycap sequences like 1️⃣ are formed by: base character + variation selector
75
101
- uniseg default: 3 columns
76
102
- uniseg with EastAsianAmbiguousWidth=2: 5 columns (usually)
0 commit comments