mattn / go-runewidth

wcwidth for golang
MIT License
609 stars 94 forks source link

Is width for EN DASH intended to be 2 instead of 1? #3

Closed dmitshur closed 10 years ago

dmitshur commented 10 years ago

Hi,

Consider the following three similar unicode characters:

'-' - Unicode Character 'HYPHEN-MINUS' (U+002D)
'–' - Unicode Character 'EN DASH' (U+2013)
'—' - Unicode Character 'EM DASH' (U+2014)

From https://github.com/shurcooL/markdownfmt/issues/7#issuecomment-46792756, I've learned that go-runewidth considers the width of the first character to be 1, and the width of second and third characters to be 2.

Is that intended?

I'm not sure how to test this reliably, but in most environments it seems that EN DASH has width that's closer to 1 than 2.

Any thoughts on this?

mattn commented 10 years ago

Could you please check latest commits?

dmitshur commented 10 years ago

Trying right now, and I expect it to work (having looked at the src change).

dmitshur commented 10 years ago
$ goe "runewidth.IsEastAsian()"
(bool)(true)

But I'm on a US setup. That doesn't seem right. Since that's returning true, the width of EN DASH is still 2 instead of 1.

Some more information for reference:

$ goe 'os.Getenv("LANG")'
(string)("en_US.UTF-8")
mattn commented 10 years ago

Ooops, Fixed.

mattn commented 10 years ago

BTW, what is goe? I want it.

mattn commented 10 years ago

Ah, I found it. https://github.com/shurcooL/goe

dmitshur commented 10 years ago

Now it works! Thanks!

mattn commented 10 years ago

Thank you