[whatwg] API for encoding/decoding ArrayBuffers into text

Glenn Maynard glenn at zewt.org
Tue Mar 20 15:50:09 PDT 2012

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:

Glenn Maynard

More information about the whatwg mailing list