gbinary

原文:https://pkg.go.dev/github.com/gogf/gf/v2@v2.6.4/encoding/gbinary

Package gbinary provides useful API for handling binary/bytes data.

​ 软件包 gbinary 提供了用于处理二进制/字节数据的有用 API。

Note that package gbinary encodes the data using LittleEndian in default.

​ 请注意,默认情况下,软件包 gbinary 使用 LittleEndian 对数据进行编码。

常量

This section is empty.

变量

This section is empty.

函数

func BeDecode

1
func BeDecode(b []byte, values ...interface{}) error

func BeDecodeToBool

1
func BeDecodeToBool(b []byte) bool

func BeDecodeToFloat32

1
func BeDecodeToFloat32(b []byte) float32

func BeDecodeToFloat64

1
func BeDecodeToFloat64(b []byte) float64

func BeDecodeToInt

1
func BeDecodeToInt(b []byte) int

func BeDecodeToInt16

1
func BeDecodeToInt16(b []byte) int16

func BeDecodeToInt32

1
func BeDecodeToInt32(b []byte) int32

func BeDecodeToInt64

1
func BeDecodeToInt64(b []byte) int64

func BeDecodeToInt8

1
func BeDecodeToInt8(b []byte) int8

func BeDecodeToString

1
func BeDecodeToString(b []byte) string

func BeDecodeToUint

1
func BeDecodeToUint(b []byte) uint

func BeDecodeToUint16

1
func BeDecodeToUint16(b []byte) uint16

func BeDecodeToUint32

1
func BeDecodeToUint32(b []byte) uint32

func BeDecodeToUint64

1
func BeDecodeToUint64(b []byte) uint64

func BeDecodeToUint8

1
func BeDecodeToUint8(b []byte) uint8

func BeEncode

1
func BeEncode(values ...interface{}) []byte

BeEncode encodes one or multiple values into bytes using BigEndian. It uses type asserting checking the type of each value of values and internally calls corresponding converting function do the bytes converting.

​ BeEncode 使用 BigEndian 将一个或多个编码 values 为字节。它使用类型断言检查每个值的 values 类型,并在内部调用相应的转换函数进行字节转换。

It supports common variable type asserting, and finally it uses fmt.Sprintf converting value to string and then to bytes.

​ 它支持公共变量类型断言,最后它使用 fmt。Sprintf 将值转换为字符串,然后转换为字节。

func BeEncodeBool

1
func BeEncodeBool(b bool) []byte

func BeEncodeByLength

1
func BeEncodeByLength(length int, values ...interface{}) []byte

func BeEncodeFloat32

1
func BeEncodeFloat32(f float32) []byte

func BeEncodeFloat64

1
func BeEncodeFloat64(f float64) []byte

func BeEncodeInt

1
func BeEncodeInt(i int) []byte

func BeEncodeInt16

1
func BeEncodeInt16(i int16) []byte

func BeEncodeInt32

1
func BeEncodeInt32(i int32) []byte

func BeEncodeInt64

1
func BeEncodeInt64(i int64) []byte

func BeEncodeInt8

1
func BeEncodeInt8(i int8) []byte

func BeEncodeString

1
func BeEncodeString(s string) []byte

func BeEncodeUint

1
func BeEncodeUint(i uint) []byte

func BeEncodeUint16

1
func BeEncodeUint16(i uint16) []byte

func BeEncodeUint32

1
func BeEncodeUint32(i uint32) []byte

func BeEncodeUint64

1
func BeEncodeUint64(i uint64) []byte

func BeEncodeUint8

1
func BeEncodeUint8(i uint8) []byte

func BeFillUpSize

1
func BeFillUpSize(b []byte, l int) []byte

BeFillUpSize fills up the bytes b to given length l using big BigEndian.

​ BeFillUpSize 使用 big BigEndian 将字节填充 b 到给定长度 l

Note that it creates a new bytes slice by copying the original one to avoid changing the original parameter bytes.

​ 请注意,它通过复制原始字节切片来创建新的字节切片,以避免更改原始参数字节。

func Decode

1
func Decode(b []byte, values ...interface{}) error

func DecodeBits

1
func DecodeBits(bits []Bit) int

DecodeBits .does decode bits to int Resolve to int

​ DecodeBits .does 将位解码为 int 解析为 int

func DecodeBitsToUint

1
func DecodeBitsToUint(bits []Bit) uint

DecodeBitsToUint .Resolve to uint

​ DecodeBitsToUint 中。解析为 uint

func DecodeToBool

1
func DecodeToBool(b []byte) bool

func DecodeToFloat32

1
func DecodeToFloat32(b []byte) float32

func DecodeToFloat64

1
func DecodeToFloat64(b []byte) float64

func DecodeToInt

1
func DecodeToInt(b []byte) int

func DecodeToInt16

1
func DecodeToInt16(b []byte) int16

func DecodeToInt32

1
func DecodeToInt32(b []byte) int32

func DecodeToInt64

1
func DecodeToInt64(b []byte) int64

func DecodeToInt8

1
func DecodeToInt8(b []byte) int8

func DecodeToString

1
func DecodeToString(b []byte) string

func DecodeToUint

1
func DecodeToUint(b []byte) uint

func DecodeToUint16

1
func DecodeToUint16(b []byte) uint16

func DecodeToUint32

1
func DecodeToUint32(b []byte) uint32

func DecodeToUint64

1
func DecodeToUint64(b []byte) uint64

func DecodeToUint8

1
func DecodeToUint8(b []byte) uint8

func Encode

1
func Encode(values ...interface{}) []byte

func EncodeBitsToBytes

1
func EncodeBitsToBytes(bits []Bit) []byte

EncodeBitsToBytes . does encode bits to bytes Convert bits to [] byte, encode from left to right, and add less than 1 byte from 0 to the end.

​ EncodeBitsToBytes 中。将位编码为字节 将位转换为 [] 字节,从左到右编码,从 0 到末尾添加少于 1 个字节。

func EncodeBool

1
func EncodeBool(b bool) []byte

func EncodeByLength

1
func EncodeByLength(length int, values ...interface{}) []byte

func EncodeFloat32

1
func EncodeFloat32(f float32) []byte

func EncodeFloat64

1
func EncodeFloat64(f float64) []byte

func EncodeInt

1
func EncodeInt(i int) []byte

func EncodeInt16

1
func EncodeInt16(i int16) []byte

func EncodeInt32

1
func EncodeInt32(i int32) []byte

func EncodeInt64

1
func EncodeInt64(i int64) []byte

func EncodeInt8

1
func EncodeInt8(i int8) []byte

func EncodeString

1
func EncodeString(s string) []byte

func EncodeUint

1
func EncodeUint(i uint) []byte

func EncodeUint16

1
func EncodeUint16(i uint16) []byte

func EncodeUint32

1
func EncodeUint32(i uint32) []byte

func EncodeUint64

1
func EncodeUint64(i uint64) []byte

func EncodeUint8

1
func EncodeUint8(i uint8) []byte

func LeDecode

1
func LeDecode(b []byte, values ...interface{}) error

func LeDecodeToBool

1
func LeDecodeToBool(b []byte) bool

func LeDecodeToFloat32

1
func LeDecodeToFloat32(b []byte) float32

func LeDecodeToFloat64

1
func LeDecodeToFloat64(b []byte) float64

func LeDecodeToInt

1
func LeDecodeToInt(b []byte) int

func LeDecodeToInt16

1
func LeDecodeToInt16(b []byte) int16

func LeDecodeToInt32

1
func LeDecodeToInt32(b []byte) int32

func LeDecodeToInt64

1
func LeDecodeToInt64(b []byte) int64

func LeDecodeToInt8

1
func LeDecodeToInt8(b []byte) int8

func LeDecodeToString

1
func LeDecodeToString(b []byte) string

func LeDecodeToUint

1
func LeDecodeToUint(b []byte) uint

func LeDecodeToUint16

1
func LeDecodeToUint16(b []byte) uint16

func LeDecodeToUint32

1
func LeDecodeToUint32(b []byte) uint32

func LeDecodeToUint64

1
func LeDecodeToUint64(b []byte) uint64

func LeDecodeToUint8

1
func LeDecodeToUint8(b []byte) uint8

func LeEncode

1
func LeEncode(values ...interface{}) []byte

LeEncode encodes one or multiple values into bytes using LittleEndian. It uses type asserting checking the type of each value of values and internally calls corresponding converting function do the bytes converting.

​ LeEncode 使用 LittleEndian 将一个或多个编码 values 为字节。它使用类型断言检查每个值的 values 类型,并在内部调用相应的转换函数进行字节转换。

It supports common variable type asserting, and finally it uses fmt.Sprintf converting value to string and then to bytes.

​ 它支持公共变量类型断言,最后它使用 fmt。Sprintf 将值转换为字符串,然后转换为字节。

func LeEncodeBool

1
func LeEncodeBool(b bool) []byte

func LeEncodeByLength

1
func LeEncodeByLength(length int, values ...interface{}) []byte

func LeEncodeFloat32

1
func LeEncodeFloat32(f float32) []byte

func LeEncodeFloat64

1
func LeEncodeFloat64(f float64) []byte

func LeEncodeInt

1
func LeEncodeInt(i int) []byte

func LeEncodeInt16

1
func LeEncodeInt16(i int16) []byte

func LeEncodeInt32

1
func LeEncodeInt32(i int32) []byte

func LeEncodeInt64

1
func LeEncodeInt64(i int64) []byte

func LeEncodeInt8

1
func LeEncodeInt8(i int8) []byte

func LeEncodeString

1
func LeEncodeString(s string) []byte

func LeEncodeUint

1
func LeEncodeUint(i uint) []byte

func LeEncodeUint16

1
func LeEncodeUint16(i uint16) []byte

func LeEncodeUint32

1
func LeEncodeUint32(i uint32) []byte

func LeEncodeUint64

1
func LeEncodeUint64(i uint64) []byte

func LeEncodeUint8

1
func LeEncodeUint8(i uint8) []byte

func LeFillUpSize

1
func LeFillUpSize(b []byte, l int) []byte

LeFillUpSize fills up the bytes b to given length l using LittleEndian.

​ LeFillUpSize 使用 LittleEndian 将字节填充 b 到给定长度 l

Note that it creates a new bytes slice by copying the original one to avoid changing the original parameter bytes.

​ 请注意,它通过复制原始字节切片来创建新的字节切片,以避免更改原始参数字节。

类型

type Bit

1
type Bit int8

Bit Binary bit (0 | 1)

​ 位 二进制位 (0 | 1)

func DecodeBytesToBits

1
func DecodeBytesToBits(bs []byte) []Bit

DecodeBytesToBits .Parsing [] byte into character array [] uint8

​ DecodeBytesToBits 中。将 [] 字节解析为字符数组 [] uint8

func EncodeBits

1
func EncodeBits(bits []Bit, i int, l int) []Bit

EncodeBits does encode bits return bits Default coding

​ EncodeBits 是否对位进行编码 返回位 默认编码

func EncodeBitsWithUint

1
func EncodeBitsWithUint(bits []Bit, ui uint, l int) []Bit

EncodeBitsWithUint . Merge ui bitwise into the bits array and occupy the length bits (Note: binary 0 | 1 digits are stored in the uis array)

​ EncodeBitsWithUint 中。将 ui 按位合并到 bits 数组中并占用长度位(注意:二进制 0 | 1 位数字存储在 uis 数组中)

最后修改 October 10, 2024: 更新 (a4b8f85)