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

Chinese characters support issue #243

Open
ns-cn opened this issue Sep 1, 2022 · 1 comment
Open

Chinese characters support issue #243

ns-cn opened this issue Sep 1, 2022 · 1 comment

Comments

@ns-cn
Copy link

ns-cn commented Sep 1, 2022

My terminal application using github.com/jroimartin/gocui which based on termbox-go, but I found some display issues.

termbox.SetCell(x, y int, ch rune, fg, bg Attribute)

The following issues are caused by setCell with Chinese character.

  • It works well when I tried to input Chinese characters one by one ,but characters overlapped likes this

my input is [中文].

image

  • Some characters disappear when I tried to input more than one Chinese characters , like this

my input is [中文中文].

image

@nsf
Copy link
Owner

nsf commented Sep 1, 2022

When working with characters that occupy more than one cell, you have to handle it yourself. There are handy libs like: https://github.com/mattn/go-runewidth, which can help you with that. Sadly I don't have much experience with it. There are examples contributed by other people though which use runewidth lib:

Maybe try running them with Chinese input/text and if it works properly for you then look at the code. And I would suggest looking at alternative UI libs as well, such as https://github.com/rivo/tview. Proper text handling is complicated and most libs I saw use the mentioned above runewidth lib, e.g.: https://github.com/rivo/tview/blob/0e6b21a48e9606d07c6bf79171d6ce05d159f9f9/util.go#L456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants