express icon indicating copy to clipboard operation
express copied to clipboard

add encoding to UTF-8 for res.json and res.jsonp

Open UlisesGascon opened this issue 1 year ago • 3 comments

Based on the IETF RFC4627:

JSON text SHALL be encoded in Unicode. The default encoding is UTF-8

I updated some references for the res.json and res.jsonp. The thing is that the tests are passing w/o additional changes so I am wondering if I am missing something here.

UlisesGascon avatar Apr 17 '24 13:04 UlisesGascon

Pretty sure this is something we would need to land in v5 right? I think explicit is sometimes better, but I would need to do some research on how different clients behave to know for sure. Have you looked beyond the spec to see if there is some reason this might have been left off despite being pretty clearly specified?

wesleytodd avatar Apr 17 '24 14:04 wesleytodd

It was left off bc code elsewhere adds it already. If you look at the http response qithout this change the charset is there in published versions.

The reason it is added elsewhere is bc nothing in that function is writing out utf-8 bytes to the response, so it leaves the part of the code that does that responsible to setting rhe charset of the bytes it actually wrote on the wire.

dougwilson avatar May 13 '24 18:05 dougwilson

Ah, that makes sense. Thanks for the clarification! Do you have a link to where it does happen, just making sure I understand this going forward.

wesleytodd avatar May 15 '24 17:05 wesleytodd