janlelis/unicode-display_width

Variation Selector-16 Support

Closed this issue · 3 comments

jquast commented

Hello,

There is a set of Emoji characters that are displayed Narrow, such as U+23F1 (Stopwatch) which unicode-display_width correctly measures as 1.

But, when joined in sequence with U+FE0F (Variation Selector-16), they become wide. This is a bit rare, as currently it is true for only 7 of ~24 popular terminals. It took me years to fully understand what the heck was going on...

You might be interested in the Specification that I have written for the python wcwidth library, the ucs-detect used to asses terminal compliance, and the test results of more than 20 popular terminals.

I have written about all of those things in this article https://www.jeffquast.com/post/ucs-detect-test-results/

jquast commented
require 'unicode/display_width'

display_width = Unicode::DisplayWidth.new(emoji: true)

puts display_width.of "\u23F1" # => 1
puts display_width.of "\u23F1\uFE0F" # => 1 .. should be 2

outputs

1
1

Hello Jeff, thanks for bringing this up. I've just released v3.0.0 which includes support for Emoji-VS16 strings to be of width 2.

I haven't added support for VS15 yet, because I am still unsure if it will be adopted, what do you think?

While investigating Emoji handling in terminals, I decided to revamp Emoji handling completely. My main learning was, that the need to display Emoji sequences as separate single Emoji won't go away. More details here.

I also have not implemented VS-15, my testing with my https://ucs-detect.readthedocs.io/ project has brought up wildly different results, I can't find any good common result! Still considering what I should do!