elvish icon indicating copy to clipboard operation
elvish copied to clipboard

lackEOLRune cause garbled

Open mrlzh opened this issue 4 years ago • 2 comments

elvish write '\u23ce' while doing setupVT.

const (
	lackEOLRune    = '\u23ce'
	lackEOL        = "\033[7m" + string(lackEOLRune) + "\033[m"
	enableSGRMouse = false
)
s += fmt.Sprintf("\033[?7h%s%*s\r \r", lackEOL, width-wcwidth.OfRune(lackEOLRune), "")

This will cause garbled while terminal is set charset gbk. elvish shows:

~/Desktop/elvish-0.14.1>
鈴?

mrlzh avatar Nov 20 '20 04:11 mrlzh

This will cause garbled while terminal is set charset gbk.

AFAIK, Elvish only supports (albeit implicitly) Unicode locales and the UTF-8 encoding for charsets. This is (sort of) documented at https://elv.sh/ref/language.html. It is a consequence of Elvish being implemented in a language that itself only treats Unicode as a first class charset.

P.S., Thanks for opening this issue. It caused me to read https://en.wikipedia.org/wiki/GBK_(character_encoding). Even though I'm a native English speaker I was aware of GB2312 but not the GBK charset.

krader1961 avatar Nov 20 '20 04:11 krader1961

@xiaq, This should be closed since I'm pretty certain Elvish will never have support for legacy, non-Unicode, charsets. The only thing we might want to do is issue a warning if the locale is not UTF-8.

krader1961 avatar Jun 26 '22 01:06 krader1961