Documentation
¶
Index ¶
- func Get7BitEncodedIntSize(value int32) int
- func PeekByte(r io.Reader) (byte, error)
- func PeekString(r io.Reader) (string, error)
- func Read7BitEncodedInt(reader io.Reader) (int32, error)
- func ReadBool(r io.Reader) (bool, error)
- func ReadByte(r io.Reader) (byte, error)
- func ReadBytes(r io.Reader, n int) ([]byte, error)
- func ReadFloat2(r io.Reader) ([2]float32, error)
- func ReadFloat3(r io.Reader) ([3]float32, error)
- func ReadFloat32(r io.Reader) (float32, error)
- func ReadFloat4(r io.Reader) ([4]float32, error)
- func ReadFloat4x4(r io.Reader) ([16]float32, error)
- func ReadFloat64(r io.Reader) (float64, error)
- func ReadInt16(r io.Reader) (int16, error)
- func ReadInt32(r io.Reader) (int32, error)
- func ReadInt64(r io.Reader) (int64, error)
- func ReadInt8(r io.Reader) (int8, error)
- func ReadString(r io.Reader) (string, error)
- func ReadUInt16(r io.Reader) (uint16, error)
- func ReadUInt32(r io.Reader) (uint32, error)
- func ReadUInt64(r io.Reader) (uint64, error)
- func Write7BitEncodedInt(writer io.Writer, value int32) error
- func WriteBool(w io.Writer, v bool) error
- func WriteByte(w io.Writer, b byte) error
- func WriteBytes(w io.Writer, bs []byte) error
- func WriteFloat2(w io.Writer, arr [2]float32) error
- func WriteFloat3(w io.Writer, arr [3]float32) error
- func WriteFloat32(w io.Writer, val float32) error
- func WriteFloat4(w io.Writer, arr [4]float32) error
- func WriteFloat4x4(w io.Writer, arr [16]float32) error
- func WriteFloat64(w io.Writer, value float64) error
- func WriteInt16(w io.Writer, value int16) error
- func WriteInt32(w io.Writer, v int32) error
- func WriteInt64(w io.Writer, value int64) error
- func WriteInt8(w io.Writer, value int8) error
- func WriteString(w io.Writer, s string) error
- func WriteUInt16(w io.Writer, val uint16) error
- func WriteUInt32(w io.Writer, val uint32) error
- func WriteUInt64(w io.Writer, value uint64) error
- type Peeker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get7BitEncodedIntSize ¶
Get7BitEncodedIntSize 计算编码一个 int32 值所需的字节数 与 Write7BitEncodedInt 保持一致的编码逻辑
func PeekString ¶
PeekString 读取下一个字符串(7BitEncode + UTF-8),但不消耗它。 要求 reader 实现 Peeker 接口,例如 bufio.Reader。
注意:如果字符串长度超过了 bufio.Reader 的缓冲区大小(默认 4KB), Peek 操作会返回 bufio.ErrBufferFull。 如果需要处理超大字符串,请在创建 bufio.Reader 时指定更大的缓冲区大小
func Read7BitEncodedInt ¶
Read7BitEncodedInt 读取 C# 格式的 7-bit encoded int 完全匹配 .NET 4.8 的实现逻辑
func ReadBool ¶
ReadBool 读取一个字节,返回 bool,如果字节非 0 则返回 true,否则返回 false 对应 C# 中的 BinaryReader.ReadBoolean
func ReadFloat32 ¶
ReadFloat32 从 r 中读取 4 个字节,以 little-endian 解码成 float32 在 C# 中是 BinaryReader.ReadSingle
func ReadFloat64 ¶
ReadFloat64 读取 8 字节浮点数 (little-endian)
func ReadString ¶
ReadString 读取 C# BinaryWriter.WriteString 格式的字符串 完全匹配 .NET 4.8 的实现逻辑 需要注意这个 7BitEncode 虽然与 LEB128 类似,但不是完全相同
func ReadUInt16 ¶
ReadUInt16 读取 2 字节无符号整数 (little-endian)
func ReadUInt32 ¶
ReadUInt32 读取 4 字节无符号整数 (little-endian)
func ReadUInt64 ¶
ReadUInt64 读取 8 字节无符号整数 (little-endian)
func Write7BitEncodedInt ¶
Write7BitEncodedInt 写入 C# 格式的 7-bit encoded int 完全匹配 .NET 4.8 的实现:支持负数,使用无符号转换
func WriteFloat32 ¶
WriteFloat32 写一个 float32 (4 bytes, little-endian) 在 C# 中是 BinaryWriter.WriteSingle
func WriteFloat64 ¶
WriteFloat64 写入 8 字节浮点数 (little-endian)
func WriteInt16 ¶
WriteInt16 写入 2 字节有符号整数 (little-endian)
func WriteInt32 ¶
WriteInt32 写一个 4 字节 int32(little-endian)
func WriteInt64 ¶
WriteInt64 写入 8 字节有符号整数 (little-endian)
func WriteString ¶
WriteString 写入 C# BinaryWriter.WriteString 格式的字符串 完全匹配 .NET 4.8 的实现逻辑 需要注意这个 7BitEncode 虽然与 LEB128 类似,但不是完全相同
func WriteUInt16 ¶
WriteUInt16 写入一个16位无符号整数(little-endian)
func WriteUInt32 ¶
WriteUInt32 写入一个 4 字节 uint32(little-endian)