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

UTF-8 Support #294

Merged
merged 1 commit into from May 1, 2022
Merged

UTF-8 Support #294

merged 1 commit into from May 1, 2022

Conversation

nervo
Copy link
Contributor

@nervo nervo commented Apr 29, 2022

Right now, utf-8 support is broken, because of golang behavior when looping with a range on string in ast readNode function

for idx, b := range s[readLen : readLen+size] {

In this case, range loop over string runes and not string bytes. As a consequence, the resulting buffer bytes does not correspond to the string bytes themselves.

See the results on https://go.dev/play/p/5pWTN0y4vUj

Fortunately, a simple byte casting fix the issue :)

	for idx, b := range []byte(s[readLen : readLen+size]) {
		p[idx] = byte(b)
	}

A test has been provided with obscure utf-8 characters.

@goccy
Copy link
Owner

goccy commented May 1, 2022

Thank you for the great PR !!! LGTM !

@goccy goccy merged commit dadf142 into goccy:master May 1, 2022
@nervo nervo deleted the utf-8-support branch May 2, 2022 06:45
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

Successfully merging this pull request may close these issues.

None yet

2 participants