|
Two major problems here:> I use a very simple JSON encoder that just scans the string character by
> character and substitutes the correct escape sequence whenever one of these
> characters is encountered. I don't think you need to resort to Base64 or
> other binary encodings unless you really want to.
(1) Not every value is a valid Unicode character. There are several
ranges defined as illegal, for various reasons.
(2) Whether 8, 16, or 32 bit, not every byte sequence is a legal UTF
representation.