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

Re: [Public WebGL] Typed Arrays & Strings

On Tue, Jun 29, 2010 at 4:35 PM, <ry@tinyclouds.org> wrote:
I like the Typed Array proposal -- it seems like one of the more sane
binary _javascript_ proposals. One important thing it's missing is the
ability to decode a chunk of UTF8 data. Is there a reason that is not
part of the spec?

This is possible to do within _javascript_, and at least IMHO doesn't need to be enshrined in the TypedArray spec's host objects.

The CommonJS crew (http://commonjs.org/) has a handful of proposals (see the Binary modules), most of which include support for encodings. Many of these could be implemented on top of a Uint8Array in _javascript_; although the performance of some of the array methods (slice, etc) would be poor, it's also questionable if those are actually desirable. Rooting around in the CommonJS discussion groups is instructive; the conversation has also jumped over to es-discuss a few times.

I recently needed similar functionality for binary data parsing, so I ended up with an ES3 "best effort" impl. of TypedArrays and also a Binary type with various encodings although to avoid dependencies, my Binary type was actually based on an "octet array" so it's not terribly efficient). I intentionally mirrored the CommonJS API ideas, since they're reasonable. Code is MIT licensed and at http://hg.secondlife.com/llsd/src/tip/js/llsd.js if you want to dig around.