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

Re: [whatwg] StringEncoding: encode() return type looks weird in the IDL

From: Glenn Maynard <glenn@zewt.org>
Date: Sun, 5 Aug 2012 11:29:03 -0500
Message-ID: <CABirCh9PQTDLjfTNJ=XFBzF_v9-k0OUL8+EPmamsfhJkZxS2FA@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: whatwg <whatwg@lists.whatwg.org>
On Sun, Aug 5, 2012 at 1:15 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> encode() should return a Uint8Array in the IDL, in my opinion.  Right now
> the prose says that it does, while the IDL has ArrayBufferView, which
> doesn't make much sense to me.

My recollection is this was to allow returning Uint16Array (or, more
specifically but currently unresolved, Uint16LEArray and Uint16BEArray) for
encoding to UTF-16 and UTF-16BE.

I guess the brokenness of Uint16Array (eg. the current lack of
Uint16LEArray) could be sidestepped by just always returning Uint8Array,
even if encoding to a 16-bit encoding (which is what it currently says to
do).  Maybe that's better anyway, since it avoids making UTF-16 a special
case.  I guess that if you're converting a string to a UTF-16 ArrayBuffer,
you're probably doing it to quickly dump it into a binary field somewhere
anyway--if you wanted to *examine* the codepoints, you'd just look at the
DOMString you started with.

Glenn Maynard
Received on Sunday, 5 August 2012 16:29:31 UTC

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