Some strings return -1 width
gauteh opened this issue · comments
Hi, we had some issues in sup (sup-heliotrope/sup#157) and it turns out that Unicode.width
returns -1 for some strings (sup-heliotrope/sup#256), example (ruby 1.9.3):
> require 'unicode'
> a = 'This is =91 a test: the first line seems to disappear from the mail body but is
still visible in the thread view.'
> Unicode.width a
=> -1
> a.length
=> 113
it's caused by the newline. what display width would you expect a multi-line string to have? you could argue that it should be the maximum width of all lines, but then again the specification for wcswidth
states that it should return -1
as soon as it encounters a control character.
so i think, whatever it is you actually need, is application specific and should be handled in sup itself.
Sounds fair, thanks for the explanation.