[whatwg] canvas, img, file api and blobs
l.mastrodomenico at gmail.com
Tue Feb 16 17:23:17 PST 2010
2010/2/16 Joel Webber <jgw at google.com>:
> On Tue, Feb 16, 2010 at 2:25 PM, Stefan Haustein <haustein at google.com>
>> so in addition to the typed arrays, we'd love to have some kind of access
>> that would be similar to Java's DataInput (+DataOutput, see
>> http://java.sun.com/j2se/1.4.2/docs/api/java/io/DataInput.html ), but with
>> endianess support....
> Agreed with Stefan's point, although technically you could implement
> getByte(), getShort(), et al with a bunch of TypedArray views onto a single
> ArrayBuffer. But this is really, really ugly, because in the general case
> you'd need 4 ByteArrays, 2 ShortArrays, etc. to deal with arbitrary offsets.
A mini language that describes arbitrary sequences of data types in
binary data is the one used by the Python module "struct"
E.g. "< 3b x 2i" represents 3 signed chars, one byte of padding and 2
signed 32-bit ints, little-endian.
It can be an inspiration for functions or methods that extract data
out of byte arrays and convert JS variables back to binary.
Another thing that people will probably ask is the possibility of
converting binary data to and from strings. Obviously for both
directions the user has to provide an encoding (e.g. UTF-8).
More information about the whatwg