Created attachment 464889 [details]
Screenshot demonstrating Safari's behaviour with and without ;charset=utf-8
According to section 8 of RFC 8259, all JSON documents must be encoded using UTF-8 / Unicode.
If a JSON file is accessed directly within Safari (for example, an API endpoint is accessed), it uses the browser's default encoding (for me, it defaulted to `Western (ISO Latin 1)` to render it. This can lead to garbled text; I discovered this as an API endpoint I created contains two emoji characters which did not render correctly within Safari. In Chrome, it renders fine.
If the `Content-Type` HTTP header is set to `application/json;charset=utf-8`, it works fine in Safari. However, the inclusion of this is widely discouraged. Not only that, IANA specifically call out that there is no `charset` parameter defined for the `application/json` media type.
So WebKit should automatically assume that `application/json` is in UTF-8 and render it as such. Otherwise, there will be more people who fall down a rabbit hole trying to work out what they've done wrong with character encoding when writing an API endpoint whilst using Safari!
I may have misread #197369 as being about how JSON is processed in XMLHTTPRequests and/or iFrames but it seems it is a duplicate to a degree. Will leave as is currently though so maintainers can assess whether they're different at all.
I think that it's an exact duplicate.
*** This bug has been marked as a duplicate of bug 197369 ***