On 8/23/2014 3:51 PM, Andrei Alexandrescu wrote:
An adapter would solve the wrong problem here. There's nothing to adapt from and
to.

An adapter would be good if e.g. the stream uses UTF-16 or some Windows
encoding. Bytes are the natural input for a json parser.

The adaptation is to take arbitrary byte input in an unknown encoding and produce valid UTF.

Note that many html readers scan the bytes to see if it is ASCII, UTF, some code page encoding, Shift-JIS, etc., and translate accordingly. I do not see why that is less costly to put inside the JSON lexer than as an adapter.

Reply via email to