hexutil

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBinaryStr

func DecodeBinaryStr(binaryStr string) (string, error)

DecodeBinaryStr 将二进制字符串解码为原始字符串表示。 DecodeBinaryStr decodes a binary string into its original string representation.

func DecodeHexStr

func DecodeHexStr(hexStr string, enc ...encoding.Encoding) (string, error)

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

func DecodeOctalStr(octalStr string) (string, error)

DecodeOctalStr 将八进制字符串解码为原始字符串表示。 DecodeOctalStr decodes an octal string into its original string representation.

func EncodeBinaryStr

func EncodeBinaryStr(str string) string

EncodeBinaryStr 将字符串编码为二进制表示。 EncodeBinaryStr encodes a string into its binary representation.

func EncodeHexStr

func EncodeHexStr(str string, enc ...encoding.Encoding) (string, error)

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

func EncodeOctalStr(str string) string

EncodeOctalStr 将字符串编码为八进制表示。 EncodeOctalStr encodes a string into its octal representation.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL