[whatwg] API for encoding/decoding ArrayBuffers into text
Joshua Bell
jsbell at chromium.org
Mon Mar 26 20:40:19 PDT 2012
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.
More information about the whatwg
mailing list