Closed Bug 1266023 Opened 5 years ago Closed 3 years ago

JSON's default charset should be UTF-8

Categories

(Core :: DOM: Core & HTML, defect, P3)

44 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 741776

People

(Reporter: amitavmohanty01, Unassigned, NeedInfo)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36

Steps to reproduce:

I have a REST api that returns JSON with header "Content-Type: application/json". According to https://tools.ietf.org/html/rfc7159 the default encoding of JSON is Unicode. However, FF initially showed the response in Western encoding. I suspect that default encoding is picked based on the default of HTTP 1.1.



Expected results:

For all responses that have json as the content type, the default encoding should be UTF-8.
Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
I have experienced the same issue, with application/json content encoded with UTF-8 being interpreted as being "windows-1252" encoding.

The server-side workaround is to get the web server to provide "Content-Type: application/json; charset=utf-8" in its responses instead of "Content-Type: application/json". Firefox then interprets the encoding as UTF-8.
Component: DOM: Core & HTML → Networking
I'm not entirely opposed to this, but if this happens (particularly in JSON.stringify), I need to know about it.
I don't think necko does anything with character encodings for JSON other than passing any info it has to the consumer.
Component: Networking → DOM: Core & HTML
Its rather ld to revive but do we have a consensus?
(In reply to amitavmohanty01 from comment #4)
> Its rather ld to revive but do we have a consensus?

*late
Priority: -- → P3
Is this still an issue? Firefox 53+ will always treat application/json resources as UTF-8 when they are loaded as documents.
For XHR, Firefox will default to UTF-8 from the start. For fetch, Firefox will always treat them as UTF-8 from the start.
Flags: needinfo?(amitavmohanty01)
See Also: → 741776
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 741776
You need to log in before you can comment on or make changes to this bug.