W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2012

[whatwg] API for encoding/decoding ArrayBuffers into text

From: Glenn Maynard <glenn@zewt.org>
Date: Tue, 20 Mar 2012 17:50:09 -0500
Message-ID: <CABirCh-5oughm+ABJO_6TscYn3BGdA-=oTNire4Zzv5xkmw3kg@mail.gmail.com>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:40 UTC