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

Re: [Public WebGL] Typed array specification comments

On Sat, Jul 9, 2011 at 2:32 PM, Ryan Ackley <ryanackley@gmail.com> wrote:
Hi, this doesn't seem like the right list to me but this is where the
specification said to leave comments so I apologize in advance if I'm
in the wrong place.

You're in the right place. 
I'm currently using the Typed Array implementation in Chrome to read a
binary file format. One thing I've found to be sorely lacking is
String handling. The ability to read and write Strings using different
encodings is a necessity. Often, with binary data, string will be
intermingled with number types. What I would love to have in DataView
are two additional methods

DOMString getString(unsigned long byteOffset, optional DOMString encoding)
void setString(unsigned long byteOffset, DOMString value, optional
DOMString encoding)

I promised Ken Russell to spec up an extension of this sort for Typed Arrays... but my personal and professional time has been crunched. Hope to be able to get to it in the next couple of months if no-one with more time beats me to it (hint hint). 

Previous discussions: 


If you need it, there is some code in http://hg.secondlife.com/llsd/src/tip/js/llsd.js which reads and writes UTF-8 strings from DataViews - search on "UTF-8" and then for callers/callees. (It's in the middle of a binary file serializer/parser so most of the code won't be relevant.) It turns out there's a lovely trick for UTF-8/UTF-16 transcoding using browser built-ins - see http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-_javascript_.html

-- Josh