charmbracelet / charmbracelet/bubbletea

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

Open
#197 8 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
44.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/charmbracelet/bubbletea/issues/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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.