[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Typed Arrays & Strings



On Wed, Jun 30, 2010 at 8:36 AM, <ry@tinyclouds.org> wrote:
On Wed, Jun 30, 2010 at 1:00 AM, Cedric Vivier <cedricv@neonux.com> wrote:
> On Wed, Jun 30, 2010 at 15:46, Vladimir Vukicevic <vladimir@mozilla.com>
> wrote:
>>
>> Is this really the same use case?  Cedric, I think you want something
>> closer to https://bugzilla.mozilla.org/show_bug.cgi?id=572522 -- but I think
>> the original request actually wanted the ability to insert true strings, not
>> binary data disguised as strings, right?
>>
>
> Hey Vlad,
> From my understanding of Ryan's first message he'd also like to decode
> arbitrary string data into TypedArrays (binary data views), but I'll let him
> confirm ;-)

Correct

To leap back in - I'd love to see browser vendors include a JS API that allows for string encoding/decoding from Uint8Arrays. At a minimum for my scenarios: ASCII, "binary", UTF-8, and Base64 (the latter with inverted semantics if the words "encode" and "decode" are used). Many libraries fail to properly deal with UTF-16 surrogate pairs, so getting it into the browser with a spec and conformance tests would be lovely.

That said, IMHO string encodings don't belong in the TypedArray spec or Uint8Array type itself. 

One approach would be a Binary/Buffer type with API like Ryan's in Node.js that "has-a" (or "is-a") Uint8Array and is what is yielded by proposed binary support in XHR, File, and WebSockets. It's certainly a clean and easy to understand API.

But... that would delay being able to lock down any of those other specs, though... so perhaps the common currency for binary data should really be simply Uint8Array (Vlad, is that what you were showing at WebGL camp?), and string<->binary encoding should exist in a separate API (e.g. like the CommonJS Encodings proposals)

(Hopefully I'm being pessimistic about the speed at which a Binary/Buffer type can be settled on.)

Vlad: does there need to be any further discussion on this list, or do you have all the requirements? Should continued discussion stay here, or be redirected to... bugzilla?