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

[whatwg] API for encoding/decoding ArrayBuffers into text

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 13 Mar 2012 23:28:09 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1203132322020.6189@ps20323.dreamhostps.com>
On Tue, 13 Mar 2012, Joshua Bell wrote:
> On Tue, Mar 13, 2012 at 4:10 PM, Jonas Sicking <jonas at sicking.cc> wrote:
> > On Tue, Mar 13, 2012 at 4:08 PM, Kenneth Russell <kbr at google.com> 
> > wrote:
> > > Joshua Bell has been working on a string encoding and decoding API 
> > > that supports the needed encodings, and which is separable from the 
> > > core typed array API:
> > >
> > > http://wiki.whatwg.org/wiki/StringEncoding
> > >
> > > This is the direction I prefer. String encoding and decoding seems 
> > > to be a complex enough problem that it should be expressed 
> > > separately from the typed array spec itself.

Some quick feedback:

 - [OmitConstructor] doesn't seem to be WebIDL

 - please don't allow UAs to implement other encodings. You should list 
   the exact set of supported encodings and the exact labels that should 
   be recognised as meaning those encodings, and disallow all others. 
   Otherwise, we'll be in a never-ending game of reverse-engineering each 
   others' lists of supported encodings and it'll keep growing.

 - What's the use case for supporting anything but UTF-8?

 - Having a mechanism that lets you encode the string and get a length 
   separate from the mechanism that lets you encode the string and get the 
   encoded string seems like it would encourage very inefficient code. Can 
   we instead have a mechanism that returns both at once? Or is the idea 
   that for some encodings getting the encoded length is much quicker than 
   getting the actual string?

 - Seems weird that integers and strings would have such different APIs 
   for doing the same thing. Why can't we handle them equivalently? As in:

     len = view.setString(strings[i],
                          offset + Uint32Array.BYTES_PER_ELEMENT,
                          "UTF-8");
     view.setUint32(offset, len);
     offset += Uint32Array.BYTES_PER_ELEMENT + len;

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 13 March 2012 16:28:09 UTC

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