[Public WebGL] [Typed arrays] String to Buffer to String

Dannii [email protected]
Sat Feb 5 06:01:45 PST 2011

I've read the archives which mention the need for a string to Buffer API,
but I don't think my particular use case was represented, so I thought I'd
share it in the hope that it might still be possible to include it in the
spec, or to encourage a separate spec to be drafter.

I work on VMs written in JS, which can run bytecode files of up to several
MB. We currently use regular arrays but I'd like to shift to typed arrays
soon. When the data is first downloaded we can get the buffer directly from
the XHR, which is great. But because I'd like to be able to set it up to
work offline as well, I want to store the files in localStorage, and read
from it in the next session. As I understand it there's no way to do this
other than just go through byte by byte. Which may be fine for desktop
browsers, but will be quite slow for mobile browsers.

Sure there might be endianess issues, but they can be dealt with just as
they have been for DataViews. The conversion function could include an
endian argument if needed.

I was also wondering, what is the justification for requiring that a
TypedArray's offset be a multiple of its element size? That makes it hard to
emulate DataView (which won't be implemented in Firefox 4).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110206/9351f152/attachment.html>

More information about the public_webgl mailing list