Reading bytes from a JavaScript string

前端 未结 9 1331
悲哀的现实
悲哀的现实 2020-11-28 02:46

I have a string containing binary data in JavaScript. Now I want to read, for example, an integer from it. So I get the first 4 characters, use charCodeAt, do s

9条回答
  •  感动是毒
    2020-11-28 03:28

    Borga's solution works perfectly. In case you want a more concrete implementation, you may want to have a look at the BinaryReader class from vjeux (which, for the records, is based on the binary-parser class from Jonas Raoni Soares Silva).

提交回复
热议问题