Documentation
¶
Overview ¶
Package hexutil 提供了一些实用工具函数,用于将字符串编码为十六进制表示,并将十六进制字符串解码为原始字符串。 The util package provides utility functions for encoding strings into their hexadecimal representation and decoding hexadecimal strings back into their original string form.
Index ¶
- func DecodeBinaryStr(binaryStr string) (string, error)
- func DecodeHexStr(hexStr string, enc ...encoding.Encoding) (string, error)
- func DecodeOctalStr(octalStr string) (string, error)
- func EncodeBinaryStr(str string) string
- func EncodeHexStr(str string, enc ...encoding.Encoding) (string, error)
- func EncodeOctalStr(str string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBinaryStr ¶
DecodeBinaryStr 将二进制字符串解码为原始字符串表示。 DecodeBinaryStr decodes a binary string into its original string representation.
func DecodeHexStr ¶
DecodeHexStr 将十六进制字符串解码为其原始字符串表示,使用指定的编码。如果未指定编码,则默认为 UTF-8。 如果输入不是有效的十六进制字符串,则返回错误。 DecodeHexStr decodes a hexadecimal string into its original string representation using the specified encoding. If no encoding is specified, it defaults to UTF-8. Returns an error if the input is not a valid hexadecimal string.
参数 (Parameters): - hexStr: 需要解码的十六进制字符串 (The hexadecimal string to be decoded). - enc: 可选参数,指定解码方式 (Optional parameter specifying the encoding).
返回值 (Returns): - string: 解码后的原始字符串 (The decoded original string). - error: 如果解码过程中出现错误,返回错误信息 (An error if any occurs during decoding).
func DecodeOctalStr ¶
DecodeOctalStr 将八进制字符串解码为原始字符串表示。 DecodeOctalStr decodes an octal string into its original string representation.
func EncodeBinaryStr ¶
EncodeBinaryStr 将字符串编码为二进制表示。 EncodeBinaryStr encodes a string into its binary representation.
func EncodeHexStr ¶
EncodeHexStr 将字符串编码为指定编码的十六进制表示。如果未指定编码,则默认为 UTF-8。 EncodeHexStr encodes a string into its hexadecimal representation using the specified encoding. If no encoding is specified, it defaults to UTF-8.
参数 (Parameters): - str: 需要编码的字符串 (The string to be encoded). - enc: 可选参数,指定编码方式 (Optional parameter specifying the encoding).
返回值 (Returns): - string: 编码后的十六进制字符串 (The encoded hexadecimal string). - error: 如果编码过程中出现错误,返回错误信息 (An error if any occurs during encoding).
func EncodeOctalStr ¶
EncodeOctalStr 将字符串编码为八进制表示。 EncodeOctalStr encodes a string into its octal representation.
Types ¶
This section is empty.