Termbox-go: When I update termbox-go, it can't print chinese or Japanese.

Created on 5 Mar 2015  路  10Comments  路  Source: nsf/termbox-go

Bug

Most helpful comment

utf8.RuneLen(c) doesn't represent cell's width. Use @mattn's library for that: https://github.com/mattn/go-runewidth

All 10 comments

I'm waiting a pull request from this guy: https://github.com/nsf/termbox-go/pull/69

But apparently he's gone somewhere.

Just merged this pull request: https://github.com/nsf/termbox-go/pull/74

Does it work now?

i wil try later thx very much!

gomatrix still prints the japanese kana's correctly at termbox-go 10f14d7408b64a659b7c694a771f5006952d336c

Looking good!

:smile: :+1:

It can print chinese too

i am using this function to print chinese character. the key problem is the width of chinese rune.

it's a quick workaround.

func print_tb(x, y int, fg, bg termbox.Attribute, msg string) {
for _, c := range msg {
//fmt.Printf("%d ", utf8.RuneLen(c))
termbox.SetCell(x, y, c, fg, bg)
if utf8.RuneLen(c) > 1 { //handle chinese rune
x += 2
} else {
x++
}
}
}

utf8.RuneLen(c) doesn't represent cell's width. Use @mattn's library for that: https://github.com/mattn/go-runewidth

thanks, i already done that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agostonbarna picture agostonbarna  路  8Comments

jroimartin picture jroimartin  路  22Comments

singingwolfboy picture singingwolfboy  路  4Comments

pjebs picture pjebs  路  3Comments

rnix picture rnix  路  3Comments