大小端字節序觀察
let byte = new egret.ByteArray();
byte.endian = egret.Endian.BIG_ENDIAN;
byte.writeInt(0x12345678);
byte.position = 0;
console.log(byte.readByte(),byte.readByte()); //0x12 0x34 (由左到右讀取字節)
byte = new egret.ByteArray();
byte.endian = egret.Endian.LITTLE_ENDIAN;
byte.writeInt(0x12345678);
byte.position = 0;
console.log(byte.readByte(),byte.readByte()); //0x78 0x56 (由右到左讀取字節)
// EndianConst是 ByteArray 的 protected 屬性, 基本上用不到
沒有留言:
張貼留言