Closed jedib0t closed 2 years ago
go-runewidth returns the value 2 for the East Asian Ambiguous Width as same as that wcwidth(3) depend on your locales. It is caused by the difference between the character width of the ruled line as represented in the terminal and the actual value returned by wcwidth(3) or runewidth. If you want it to be fixed behavior under certain conditions, change the value of the EastAsianWidth variable.
Thanks for the response. Will provide a workaround for my library's users.
Hello!
I maintain a golang library for drawing ASCII tables at https://github.com/jedib0t/go-pretty and this is one of the few dependencies I have, to calculate rune width for drawing the tables. Sample: https://go.dev/play/p/I6uxssyXxhN?v=goprev
Now, a couple of users reported some alignment issues, and after some investigation I figured that the Width returned for Box Drawing characters were not the expected values when
LANG=zh_CN.UTF-8
or when EastAsianWidth=true is set in go-runewidth.To replicate the bug, I create this program -- say
foo.go
:Output:
Is this behavior right, or am I using runewidth.RuneWidth/StringWidth incorrectly?