[whatwg] API for encoding/decoding ArrayBuffers into text

On Tue, Mar 20, 2012 at 12:39 PM, Joshua Bell <jsbell at chromium.org> wrote:

> 1. Only support encodings with stateless coding (possibly down to a minimum
> of UTF-8)
> 2. Only provide an API supporting non-streaming coding (i.e. whole
> strings/whole buffers)
> 3. Expand the API to return encoder/decoder objects that capture state
>
> Any others?
>
> Trying to do simplify the problem but take on both (1) and (2) without (3)
> would lead to an API that could not encompass (3) in the future, which
> would be a mistake.
>

I don't think that's obviously a mistake.  Only the nastiest, wartiest of
legacy encodings require it.

That said, it's fairly simple to later return an additional state object
from the previously proposed streaming APIs, eg.

result = decode(str, 0, outputView)
// result.outputBytes == 15
// result.nextInputByte == 5
// result.state == opaque object

result2 = decode(str, result.nextInputByte, outputView, {state:
result.state});

-- 
Glenn Maynard

Received on Tuesday, 20 March 2012 15:50:09 UTC