Description
I've noticed that the wctwidth / wcswidth function in the vty library seems to miscalculate the width of certain text, particularly those which involve the Variation Selector-16 (U+FE0F). For example, the emoji 🏞️ (National Park) is composed of U+1F3DE followed by U+FE0F. This should be rendered as a colorful double-width emoji. However, the current width calculation doesn't seem to reflect this correctly.
Steps to Reproduce
- Use the
wctwidth function to calculate the width of the character 🏞️ (which is U+1F3DE followed by U+FE0F).
- Observe that the calculated width does not match the expected width (normally, it should be 2).
Example Code
ghci> import Graphics.Text.Width
ghci> wcswidth "🏞️" -- This should ideally return 2, but it doesn't
The wcswidth function should return 2 for the character 🏞️ as it should be considered a double-width emoji. But the wcwidth function currently returns 1, which does not account for the Variation Selector-16 and results in incorrect rendering where the cursor position becomes misaligned in terminals.
Environment
- OS: ArchLinux
- Terminal: Konsole
- Vty Version: 6.2
Additional Context
Variation Selector-16 (U+FE0F) is used to indicate that the preceding character should be displayed as an emoji. Proper support for this selector is crucial for accurate width calculation of such Unicode sequences.
For reference, this issue has been observed with Windows Terminal too, and here is some relevant information:
Would be great to discuss potential fixes or workarounds for this issue. Thank you for your attention and support!
Description
I've noticed that the
wctwidth/wcswidthfunction in thevtylibrary seems to miscalculate the width of certain text, particularly those which involve the Variation Selector-16 (U+FE0F). For example, the emoji🏞️(National Park) is composed ofU+1F3DEfollowed byU+FE0F. This should be rendered as a colorful double-width emoji. However, the current width calculation doesn't seem to reflect this correctly.Steps to Reproduce
wctwidthfunction to calculate the width of the character🏞️(which isU+1F3DEfollowed byU+FE0F).Example Code
The
wcswidthfunction should return2for the character🏞️as it should be considered a double-width emoji. But thewcwidthfunction currently returns1, which does not account for the Variation Selector-16 and results in incorrect rendering where the cursor position becomes misaligned in terminals.Environment
Additional Context
Variation Selector-16 (U+FE0F) is used to indicate that the preceding character should be displayed as an emoji. Proper support for this selector is crucial for accurate width calculation of such Unicode sequences.
For reference, this issue has been observed with Windows Terminal too, and here is some relevant information:
U+1F3DEcombined withU+FE0Fshould be considered double-width.Would be great to discuss potential fixes or workarounds for this issue. Thank you for your attention and support!