weechat / weechat

The extensible chat client.
https://weechat.org
GNU General Public License v3.0
2.92k stars 327 forks source link

Unicode chars with zero-width joiner (U+200D) are displayed as separate chars in chat and bars #1857

Closed flashcode closed 1 year ago

flashcode commented 1 year ago

Bug summary

Unicode chars with zero-width joiner (U+200D) are displayed as separate chars in chat and bars (OK in bare display).

For example: U+1F62E U+200D U+1F4A8

Display in chat and bars (broken):

image

Display in bare display (OK):

image

Steps to reproduce

  1. Run WeeChat in a terminal able to display such Unicode char, like WezTerm or kitty (not to be confused with KiTTY which is a fork of PuTTY).
  2. Execute this command: /eval /print ${\U1F62E\u200D\U1F4A8}

Current behavior

2 separate unicode chars are displayed instead of one that is face exhaling. Display is OK in bare display.

Expected behavior

Display is OK everywhere: chat, bars and bare display.

Suggested solutions

Compute number of columns displayed for all chars at once, display them together instead of one by one. This fix is not easy and require some changes in the way to compute length on screen and to display chars.

Note: this could be also an issue with ncurses and then not fixable in WeeChat itself (supposing ncurses is kept).


trygveaa commented 1 year ago

Thanks to Lord on IRC for noting that this works in Alpine. I saw that Alpine uses the latest patches for ncurses instead of the latest release, and confirmed that it works on Arch to with the latest patch of ncurses. I bisected the patches, and see that it was fixed in patch 20220612. So nothing needs to be done to print this correctly.

However, now that it's printed correctly it will cause display issues in wezterm, because wezterm considers the emoji to be 2 characters wide (which I would argue is correct), while WeeChat/glibc looks at the separate characters which makes it 4 characters wide. This is also an issue with emojis using U+FE0F, and there are some more details on how different terminal emulators behave, so maybe I should open a separate issue about that, and then this can be closed?

flashcode commented 1 year ago

Closing this one as invalid (bug is in ncurses). A new issue has been opened for the wrong number of columns used: #1861.