[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] [Typed arrays] String to Buffer to String
- To: public_webgl <email@example.com>
- Subject: [Public WebGL] [Typed arrays] String to Buffer to String
- From: Dannii <firstname.lastname@example.org>
- Date: Sun, 6 Feb 2011 01:01:45 +1100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=JNUKcGvoj5qNy2QJKHkshz8MHM3pUl5Ee9Of6Q9zpO4=; b=Ku/WLG93OA3naP80OgEl/H1MW/pnVDpKsh4tcBzCsC4UsfqRa1CzmOSPv6zs1eiLl6 K/5TayKAeV64WliBmOuRYUC8v2ilOLpBbLPsi55toZ96yqs1b/6868GtxIEKCXXhV5Aa esj0gNou1ZT4dQkoh+NQb1FvZAdhIjmgQZh6c=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=xCcQ52mYcH0q7KghR/m9sqny6cIGQkGA8g02RcX5hF1zFXfhaExujuhcL/I0UzTknX BJ/u/0ApD6w3WauPc1C0Qrd+Zfk0dmrEfN5aV4MVpDIONF6AREEq3DhBVmrU+HvOIglu PuW5wppI7R0ziJadHk+kQ6nxnjIR16wZWC+EE=
- List-id: Public WebGL Mailing List <public_webgl.khronos.org>
- Sender: email@example.com
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).