shiena / ansicolor

Ansicolor library provides color console in Windows as ANSICON for Golang.
https://pkg.go.dev/github.com/shiena/ansicolor
MIT License
229 stars 40 forks source link

When parameter has characters which current console can not display, the next one character disappears #11

Closed hymkor closed 8 years ago

hymkor commented 8 years ago

At printing Japanese letter on chcp 65001, they are not displayed because the font is not enough. It is not problem. But, on printing next string, the first character is not displayed though it is alphabet.

(Japanese: chcp 65001 で、日本語を出そうとすると、フォントの関係で日本語が表示されません。それ自体は当然なのですが、それに続く次回の出力で表示可能なはずの1文字が欠けてしまう問題を確認しました。表示できない文字列が入力で入ってくる以上、正常動作できなくて当然ですが、もし可能であれば何かしら対応いただけると幸いです)

package main

import (
        "fmt"
        "os"

        "github.com/shiena/ansicolor"
)

func main() {
        w := ansicolor.NewAnsiColorWriter(os.Stdout)
        fmt.Fprint(w, "Green(\x1B[32mみどり\x1b[0m)")
        fmt.Fprint(w, "Blue(\x1B[34mあお\x1B[0m)")
        fmt.Fprint(w, "\n")
}

// vim:set fenc=utf8:

chcp-932

-> No Problem

chcp-65001

-> The Problem is that Blue's B is not displayed.

shiena commented 8 years ago

@zetamatta Thank you for reporting bugs. I will recommended mattn/go-colorable if you want to quickly resolve. Maybe, cause is to split from a string to a byte array. mattn/go-colorable is not broken string because it is split in UTF8.

hymkor commented 8 years ago

@shiena Thank you for answer. I does not need to resolve quickly. (This is a small problem) So, I want to decide to use which library when I release the next version of my application.

(Japanese: ご回答ありがとうございます。解決は特に急がないので、ライブラリを変更するかどうかは、import している自作アプリのリリース時に改めて検討したいと思います )