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

go/constant: stringVal.String returns invalid UTF-8 #14262

Closed
alandonovan opened this issue Feb 8, 2016 · 1 comment
Closed

go/constant: stringVal.String returns invalid UTF-8 #14262

alandonovan opened this issue Feb 8, 2016 · 1 comment

Comments

@alandonovan
Copy link
Contributor

When this program is run using Go 1.6: http://play.golang.org/p/uGmwQKxWyj, it crashes:

% go run a.go
"بموجب الشروط التالية نسب المصنف — يج�...
2016/02/08 14:59:11 output is not valid UTF-8!

It sliced a rune in half because the UTF-8 decoder is not advancing its input.

The corrected loop body should say:

    _, size := utf8.DecodeRuneInString(s[i:])
@ianlancetaylor ianlancetaylor added this to the Go1.6Maybe milestone Feb 8, 2016
@gopherbot
Copy link

CL https://golang.org/cl/19361 mentions this issue.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants