Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: could not decode rune. Windows-1251 (Cyrillic) #197

Open
alexey-sderzhikov opened this issue Jan 21, 2022 · 5 comments
Open

Error: could not decode rune. Windows-1251 (Cyrillic) #197

alexey-sderzhikov opened this issue Jan 21, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@alexey-sderzhikov
Copy link

Hi, your framework is very cool, it inspired me to make some helpful app for me and my colleagues!

It works fine on Linux, but most employees in my company use Windows and they get error "could not decode rune",
when typing cyrillic symbols, like (ш, б, ж etc).

I find place in source code:

// Translate input into runes. In most cases we'll receive exactly one
// rune, but there are cases, particularly when an input method editor is
// used, where we can receive multiple runes at once.
for i, w := 0, 0; i < len(b); i += w {
	r, width := utf8.DecodeRune(b[i:])
	log.Printf("number bytes: %v, buffer:%v. bytes:%b after decode to rune: %v", numBytes, buf, b, r)
	if r == utf8.RuneError {

		return nil, errors.New("could not decode rune")
	}
	runes = append(runes, r)
	w = width
}

I think problem with windows-1251 (Cyrillic) encode.
They tried set UTF-8 support, like in this issue #153, but it doesn't work.

How can I handle input bytes before framework handle it? Maybe this help me to decode bytes to correct utf8 format?
Or maybe you can help another way?

@knz
Copy link
Contributor

knz commented Aug 25, 2022

I think this was fixed in #343. Can you check?

@alexey-sderzhikov
Copy link
Author

Okey, now app doesn't exits with panic, but when i type it looks like "®¢ ë«ä¤ ®ë¤¢ ã誮ãè¤ë¢". It's not my language))))). Can I adjust app for work with windows-1251 (Cyrillic) encode?

@muesli muesli added the bug Something isn't working label Oct 5, 2022
@Dmitrevicz
Copy link

Sorry for bothering, but any chances or plans of this being fixed sooner or later?

Some more info from me about related issue.

For example. When I type cyrillic russian "ф" character (CP1251 code: 244) - app missreads it as "ä" (CP1252 code: 228). And "г" (CP1251 code: 227) --> "£" (CP1252 code: 163).
Maybe smth is broken with Code Page detection (CP1251/CP1252) or something.
Looks like on Windows (maybe when russian is used as a system lang?) bubbletea input text is stuck with CP1252 characters only.

bug-bubbletea-broken-inputs-2024-04-12-001 — копия

Locale set in terminal: ru_RU.UTF-8.

$ locale
LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_ALL=

Tried on Windows 10, same with: cmd, git bash, powershell.

@knz
Copy link
Contributor

knz commented Apr 12, 2024

Your locale does not match your input encoding.

Have you tried locale ru_RU.CP1251?

@Dmitrevicz
Copy link

Have you tried locale ru_RU.CP1251?

I don't really appreciate the idea of forcing my end-users to mess with their system's or terminal config.

Your locale does not match your input encoding.

My guess is so that bubbletea's input reader implementation might be kinda bugged on Windows. But unfortunately don't really have time to check it myself right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants