【Byte】 —— 极限研究

来源:互联网 发布:淘宝签到在哪 编辑:程序博客网 时间:2024/06/10 14:47


Byte —— 八位整数(-128~127、0~255)


======== ByteArray ========(统一从右向左读,使用length = xx时,从左边削除...)


==== Endian ====(不影响字节数组自身的读写顺序!!只影响传输顺序!!)

bigEndian —— 高位在前(默认),Internet 上的大多数服务器使用 bigEndian 字节顺序,因为“网络字节顺序”为 bigEndian。

littleEndian —— 低位在前,Intel x86 体系结构使用该字节顺序。


==== Method ==== 12(write)× 14(read)

<1> writeByte(value:int) : void >>>> 带符号的 8 位整数,最基本单位。 —— 使用参数的低 8 位。忽略高 24 位。,(value + 128) % 256 - 128(-128 ~ 127)

<2> writeShort(value:int) : void >>>> 带符号的 16 位整数。 —— 使用参数的低 16 位。忽略高 16 位。(-32768 ~ 32767)

<4> writeInt(value:int):void >>>> 带符号的 32 位整数。 —— (-2147483648 ~ 2147483647)

<4> writeUnsignedInt(value:uint):void >>>> 无符号的 32 位整数。 —— (0 ~ 4294967295)

<1> writeBoolean(value:Boolean):void >>>> 布尔值。 —— false(0),true(1)

<4> writeFloat(value:Number):void >>>> 单精度(32 位)浮点数。 —— ????

<8> writeDouble(value:Number):void >>>> 双精度(64 位)浮点数。 —— ????

<2+??> writeUTF(value:String):void >>>> 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节。

<2+??> readUTF():String >>>> 从字节流中读取一个 UTF-8 字符串。

<??> writeUTFBytes(value:String):void >>>> 将 UTF-8 字符串写入字节流。类似于writeUTF() 方法,但writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀。

<??> readUTFBytes(length:uint):String >>>> 由指定长度的 UTF-8 字节组成的字符串。

<8> writeObject(object:*):void >>>> 将对象以 AMF 序列化格式写入字节数组。

<8> writeMultiByte(value:String, charSet:String):void >>>> 使用指定的字符集将多字节字符串写入字节流。

<8> writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void >>>> 将指定字节数组bytes(起始偏移量为offset,从零开始的索引)中包含length 个字节的字节序列写入字节流。

<1> readUnsignedByte() : uint >>>> 无符号的 8 位整数。 —— value + 128(0 ~ 255)

<2> readUnsignedShort() : uint >>>> 无符号的 16 位整数。 —— (0 ~ 65535)

原创粉丝点击