irc-core icon indicating copy to clipboard operation
irc-core copied to clipboard

Rewrite cleanText to strip zero width spaces characters

Open axman6 opened this issue 1 year ago • 1 comments

This is a fairly hack fix for the issue that I appear to be the only one suffering from. Certain non-ascii characters cause text to get corrupted in my terminal when using glirc - when connected

(macOS ->) (Alacritty|Terminal.app) -> Mosh -> tmux -> glirc.

All have been configured to understand and use utf-8 characters, but the zero width spaces that get included in the nicks from haskellbridge cause things get garbled. See screen shot and particularly note that the text immediately after nicks:

Screenshot 2024-05-01 at 20 58 42

This problem is so bad that it affects other tmux windows when I switch between them. While other unicode characters like emojis cause problems, the prevalence of the zero width space (see https://www.unicode.org/charts/PDF/U2000.pdf - code 0x200B) is used in the haskellbridge matrix bot on Libera.chat, which causes glirc to be nearly unreadable for me when many matrix users are speaking.

I'm sure this isn't the best implementation of the fix, but I couldn't think of an appropriate character that '\8203' should be replaced with that wouldn't look strange. More than happy to implement alternatives, this is more for discussion that necessarily the final fix.

axman6 avatar May 01 '24 11:05 axman6

Another example from a channel with very little activity after switching from #ghc

Screenshot 2024-05-01 at 21 09 33

axman6 avatar May 01 '24 11:05 axman6

It looks like the next release is making good progress, any chance this could be merged in too? I'm using it locally and haven't noticed any issues, and it fixes the bug shown above. Ping @glguy @TheDaemoness

axman6 avatar Aug 12 '24 01:08 axman6

This behavior might be Mosh's fault due to a disagreement between the Mosh client and server on the width of the, uh, zero-width space. See https://github.com/mobile-shell/mosh/issues/234#issuecomment-413336927. Does this still occur when you run glirc directly under Alacritty or Terminal.app on macOS?

TheDaemoness avatar Aug 12 '24 23:08 TheDaemoness

Fixed by #125

glguy avatar Aug 13 '24 18:08 glguy