Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Fix wrong behavior in marshalling invalid UTF-8 byte with EscapeHTML=false#664

Open
kz-sher wants to merge 2 commits into
json-iterator:masterfrom
kz-sher:fix-json-marshal-invalid-utf8-char
Open

Fix wrong behavior in marshalling invalid UTF-8 byte with EscapeHTML=false#664
kz-sher wants to merge 2 commits into
json-iterator:masterfrom
kz-sher:fix-json-marshal-invalid-utf8-char

Conversation

@kz-sher

@kz-sher kz-sher commented Mar 9, 2023

Copy link
Copy Markdown

See #663

@kz-sher kz-sher changed the title Fix invalid behavior in marshalling invalid UTF-8 byte with EscapeHTML=false Fix wrong behavior in marshalling invalid UTF-8 byte with EscapeHTML=false Mar 9, 2023
@kz-sher

kz-sher commented Mar 13, 2023

Copy link
Copy Markdown
Author

@taowen

@taowen

taowen commented Mar 13, 2023

Copy link
Copy Markdown
Contributor

split it into two functions, duplicate the code is ok

@kz-sher kz-sher force-pushed the fix-json-marshal-invalid-utf8-char branch from 88045f2 to ca479af Compare March 13, 2023 09:56
@kz-sher

kz-sher commented Mar 13, 2023

Copy link
Copy Markdown
Author

done

@taowen

taowen commented Mar 13, 2023

Copy link
Copy Markdown
Contributor

this will affect all users of writeStringSlowPath. do not want to make such a impactful change.

@kz-sher

kz-sher commented Mar 13, 2023

Copy link
Copy Markdown
Author

@taowen This is the same with https://go.dev/src/encoding/json/encode.go#L1029. The code changes essentially restrict contents to be UTF-8. According to golang/go#36686 (comment), I think the users should have accepted this behavior. If they opt for another encodings, they should follow JSON convention by doing transformation in advance.

@taowen

taowen commented Mar 15, 2023

Copy link
Copy Markdown
Contributor

they can opt to use the standard library

@kz-sher

kz-sher commented Mar 16, 2023

Copy link
Copy Markdown
Author

@taowen I think jsoniter is created to be one of the better alternatives of official JSON pkg. Should you be considering this feature to be added in another ways such as having Config.MarshalByteWithUTF8Coerced option? It seems like its Java version has this support.

@taowen

taowen commented Mar 16, 2023

Copy link
Copy Markdown
Contributor

you may add my wechat "nctaowen"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants