bubbletea
bubbletea copied to clipboard
key.go does not respect current codepage leading to utf8.RuneError
Bubbletea does not respect the current codepage while parsing the console input from a user: https://github.com/charmbracelet/bubbletea/blob/624343388b02eb2f5199ee8fcd29961ba3b17581/key.go#L515
It assumes the input encoding is utf8.
I'm using Windows Terminal. And chcp
PS C:\Windows\system32> chcp
Active Codepage: 850.
shows default encoding is Codepage 850
== DOS-Latin-1
.
If I'm entering characters (in a textarea
widget) on my german keyboard like ß, ö, ä, ü
this leads to utf8.RuneError
.
I could fix key.go just for my system by using:
var decoder = charmap.CodePage850.NewDecoder()
utf8bytes, err := decoder.Bytes(b[i:])
r, width := utf8.DecodeRune(utf8bytes)
instead of
r, width := utf8.DecodeRune(b[i:])
but this is no good nor general solution.
I assume a good solution would include using something like GetConsoleCP()
Futhermore pressing buttons on my keyboard like POS1 / END inserts a bracket to the textarea which suggests parsing of control characters does not work.
Is this a known problem?
Futhermore pressing buttons on my keyboard like POS1 / END inserts a bracket to the textarea which suggests parsing of control characters does not work.
Is this a known problem?
This should be fixed by 2fe4aad5e60ed5ea53ee1fbe546db429da748832.
r, width := utf8.DecodeRune(b[i:])
Shouldn't this have been converted to utf8 by the localereader above?
Probably related: #153 and #343.