- From: Charles Pritchard <chuck@jumis.com>
- Date: Wed, 11 Jan 2012 14:45:00 -0800
- To: Webapps WG <public-webapps@w3.org>
Currently, we can asynchronously use BlobBuilder with FileReader to get an array buffer from a string. We can of course, use code to convert String.fromCharCode into a Uint8Array, but it's ugly. The StringEncoding proposal seems a bit much for most web use: http://wiki.whatwg.org/wiki/StringEncoding All we really ever do is work on DOMString, and that's covered by UTF8. As following file shows, DOMString to ArrayBuffer conversion is about 30 lines of code (start at line 125): http://code.google.com/p/stringencoding/source/browse/encoding.js It seems like this kind of type conversion could be handled more efficiently and be less error prone on programmers like myself, who often forget to test with multibyte strings. I'm sure this has popped up many times before on the list. Thought I'd put it out there again. We could just tweak the ArrayBuffer constructor to support DOMString as an argument. Currently, it supports length. -Charles
Received on Wednesday, 11 January 2012 22:45:30 UTC