[whatwg] API for encoding/decoding ArrayBuffers into text
glenn at zewt.org
Fri Mar 16 15:26:34 PDT 2012
On Fri, Mar 16, 2012 at 4:44 PM, Charles Pritchard <chuck at jumis.com> wrote:
> The DataView set of methods already does this work. The raw arrays are
> supposed to have platform endianness.
That's wrong. This is web API design 101; everyone should know better than
this by now. Exposing platform endianness is setting the platform up for
massive incompatibilities down the road.
In reality, the spec is moot here: if anyone does implement typed arrays on
a production big-endian system, they're going to make these views
little-endian, because doing otherwise would break countless applications,
essentially all of which are tested only on little-endian systems. Web
compatibility is a top priority to browser implementations.
(DataView isn't relevant here; it's used for different access patterns. To
access arrays of data embedded in an ArrayBuffer, you use views, not
DataView. Use DataView if you have a packed data structure with
variable-size fields, such as the metadata in a ZIP local file header.)
More information about the whatwg