JavaScript在浏览器中是否支持ByteArray类? [英] Does JavaScript support a ByteArray class in the browser?
问题描述
ByteArray 类提供了用于优化读取,写入和使用二进制数据的方法和属性。
如何使用字节数组教程。
我正在寻找一种与链接的API非常相似的API。
我正在寻找浏览器不提供hack或解决方法的类。链接的问题未提供答案。如果有,请提供文档链接。
有些人链接到另一个问题,但是没有回答我的问题。
更新:不在名单上的人向我指出了此类:
https://gist.github.com/sunetos/275610#file-bytearray-js
它具有大多数或所有读取方法,但没有任何写入方法,并且不是浏览器的本机。
现代浏览器支持 Uint8Array
,即JavaScript的 TypedArray
类。
var data = new Uint8Array(8);
var data = new Uint8Array([0x10,0x12]);
它没有用于编码/解码Unicode字符串的内置方法。有关如何执行此操作的示例,请参见在字符串和ArrayBuffer之间进行转换。
The ByteArray class provides methods and properties to optimize reading, writing, and working with binary data.
How to use byte arrays tutorial.
I'm looking for a very similar API as the one linked.
I'm looking for a class the browser provides not hack or workaround. The linked question does not provide the answer. If it does please provide a link to the documentation.
Some one linked to another question but that did not answer my question.
Update: Someone off list pointed me to this class:
https://gist.github.com/sunetos/275610#file-bytearray-js
It has most or all of the read methods but none of the write methods and it's not native to the browser.
Modern browsers support Uint8Array
, one of JavaScript's TypedArray
classes.
var data = new Uint8Array(8);
var data = new Uint8Array([0x10, 0x12]);
It does not have built-in methods for encoding/decoding Unicode strings. See Converting between strings and ArrayBuffers for examples of how to do that.
这篇关于JavaScript在浏览器中是否支持ByteArray类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!