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

[whatwg] API for encoding/decoding ArrayBuffers into text

From: Joshua Bell <jsbell@chromium.org>
Date: Mon, 26 Mar 2012 20:40:19 -0700
Message-ID: <CAD649j5Dea_3joqugrYET5csF0wRe-147B-_4qTC+PPqGJLY1w@mail.gmail.com>
On Mon, Mar 26, 2012 at 6:24 PM, Glenn Maynard <glenn at zewt.org> wrote:

> I guess.  It doesn't seem that important, since it's just a few lines of
> code.  If this is done, I'd suggest that this helper API *not* have any
> special support for streaming (not to disallow it, but not to have any
> special handling for it, either).  I think streaming has little overlap
> with null-terminated fields, since null-termination is typically used with
> fixed-size buffers.  It would complicate things; for example, you'd need
> some way to signal to the caller that a null terminator was encountered.
>

Agreed.

Also worth relying to this thread is that in addition to null termination
there have been requests for other terminators, such as 0xFF which is an
invalid byte in a UTF-8 stream and thus a lovely terminator. Other byte
sequences were mentioned. (This was over in the Khronos WebGL list for
anyone who wants to dig it up. It was tracked as an unresolved ISSUE in the
spec.)

This supports the assertion that we should not special case null
terminators, but instead provide general (and highly optimizable) utilities
like memchr operating on buffers, since we can't anticipate every usage in
higher-level APIs like the one under discussion.
Received on Monday, 26 March 2012 20:40:19 UTC

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