Re: Ways to detect that XXXX in JSON \uXXXX does not correspond to a Unicode character?

From: Daniel Bünzli <daniel.buenzli_at_erratique.ch>
Date: Fri, 8 May 2015 03:22:01 +0200

Le vendredi, 8 mai 2015 à 02:16, Philippe Verdy a écrit :
> It would be more exact to say that JSON strings, just like strings in Javascript and Java or many programming languages are just binary streams of 16-bit code units.

I suggest you have a careful read at RFC 7159 as it specifically implies that this is not the model it supports (albeit using broken or let's say ambiguous/imprecise Unicode terminology).
  
> Then the JSON processor will decode this text and will remap it to an internal UTF-16 encoding (for characters that are not escaped) and the "\uXXXX" will be decoded as plain 16-bit code units. The result will be a stream of 16-bit code units, which can then externally be outpout and encoded or stored in any convenient encoding that preserves this stream, EVEN if this is not valid UTF-16.

I don't know where you get this from but you won't find any mention of this in the standard. We are dealing with text, Unicode scalar values, not encodings. At the risk of repeating myself, read section 8.2 of RFC 7159.

Best,

Daniel
Received on Thu May 07 2015 - 20:23:30 CDT

This archive was generated by hypermail 2.2.0 : Thu May 07 2015 - 20:23:31 CDT