0

I have a small issue. I'm trying to read a binary file with header made of multiple characters and the data part containing multiple 16bit integer. My problem is reading integer. If I read the file in PHP or Java I can see that the higher byte goes first followed by the lower byte. Let say number 300 if reading bytes(8bit integer) will be written like 1 followed by 44. But I realized using ArrayBuffer in Javascript (HTML5) when I create an unsigned 16 bit integer view of the ArrayBuffer containing my file - Uint16Array reads it the other way around - instead of 300 I get 11,265. So the first byte is considered lower followed by higher byte. It is not a big issue since I can always stick to reading 8 bit integers I'm just curious is there any rule how to read or write binary files or is it just a design choice?

4

0 に答える 0