You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example above, jsoniter stores the string "\xa8" without interpretation: the value it stores is equivalent to string([]byte{0xa8}). In Marshal, however, the string "\xa8" is interpreted as unicode with the malformed "\xa8" replaced with the replacement character \ufffd (seen above as [239 191 189]).
In contrast, encoding/json interprets the contents of the string as malformed unicode and replaces 0xa8 with the unicode replacement character \uffd in both the unmarshal and marshal steps.
This causes Unmarshal, Marshal, Unmarshal to be different from a single Unmarshal in these cases which is unexpected.
When unmarshaling quoted strings, invalid UTF-8 or invalid UTF-16 surrogate pairs are not treated as an error. Instead, they are replaced by the Unicode replacement character U+FFFD.
The text was updated successfully, but these errors were encountered:
Example program:
Program output:
In the example above, jsoniter stores the string "\xa8" without interpretation: the value it stores is equivalent to string([]byte{0xa8}). In Marshal, however, the string "\xa8" is interpreted as unicode with the malformed "\xa8" replaced with the replacement character \ufffd (seen above as [239 191 189]).
In contrast, encoding/json interprets the contents of the string as malformed unicode and replaces 0xa8 with the unicode replacement character \uffd in both the unmarshal and marshal steps.
This causes Unmarshal, Marshal, Unmarshal to be different from a single Unmarshal in these cases which is unexpected.
From https://golang.org/pkg/encoding/json/#Unmarshal:
The text was updated successfully, but these errors were encountered: