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

Incorrect encoding on "香蕉人" #1

Open
clsung opened this issue Feb 3, 2017 · 3 comments
Open

Incorrect encoding on "香蕉人" #1

clsung opened this issue Feb 3, 2017 · 3 comments

Comments

@clsung
Copy link
Owner

clsung commented Feb 3, 2017

$ go get github.com/skip2/go-qrcode/qrcode
$ qrcode "中文測試" > out.png; ./grcode out.png
Data 中文測試
$ qrcode "香蕉人" > out.png; ./grcode out.png
Data 鬥呵負莠コ

@luyaotsung
Copy link

香蕉人??

@ghost
Copy link

ghost commented Apr 24, 2018

for chinese string, may need iconv.

中文需要用iconv转换下

// ScanQRcode scan qrcode(in fact, any one of zbar bar codes)
func ScanQRcode(path string) ([]string, error) {
	qrcodes := []string{}

	results, err := grcode.GetDataFromFile(path)
	if err != nil {
		return qrcodes, err
	}

	for _, result := range results {
		cd, err := iconv.Open("shift_jis", "utf-8")
		if err == nil {
			defer cd.Close()
			result1 := cd.ConvString(result)
			qrcodes = append(qrcodes, result1)
		} else {
			return qrcodes, err
		}
	}

	return qrcodes, nil
}

@ghost
Copy link

ghost commented Aug 14, 2018

@clsung

我更新库后好像不需要再转码了,直接输出正常

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