Documentation ¶
Index ¶
- Variables
- func AppendInt(dst []byte, num int64) []byte
- func AppendUint(dst []byte, num uint64) []byte
- func Decode(src []byte) ([]byte, error)
- func DecodeString(src string) ([]byte, error)
- func DecodeToBuf(dst []byte, src []byte) ([]byte, error)
- func Encode(src []byte) []byte
- func EncodeToBuf(dst []byte, src []byte) []byte
- func EncodeToString(src []byte) string
- func FormatInt(num int64) []byte
- func FormatUint(num uint64) []byte
- func ParseInt(src []byte) (int64, error)
- func ParseUint(src []byte) (uint64, error)
- type CorruptInputError
- type Encoding
- func (enc *Encoding) AppendInt(dst []byte, num int64) []byte
- func (enc *Encoding) AppendUint(dst []byte, num uint64) []byte
- func (enc *Encoding) Decode(src []byte) ([]byte, error)
- func (enc *Encoding) DecodeString(src string) ([]byte, error)
- func (enc *Encoding) DecodeToBuf(dst []byte, src []byte) ([]byte, error)
- func (enc *Encoding) Encode(src []byte) []byte
- func (enc *Encoding) EncodeToBuf(dst []byte, src []byte) []byte
- func (enc *Encoding) EncodeToString(src []byte) string
- func (enc *Encoding) FormatInt(num int64) []byte
- func (enc *Encoding) FormatUint(num uint64) []byte
- func (enc *Encoding) ParseInt(src []byte) (int64, error)
- func (enc *Encoding) ParseUint(src []byte) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
var StdEncoding = NewEncoding(encodeStd)
StdEncoding is the default base62 encoding using alphabet [A-Za-z0-9].
Functions ¶
func AppendInt ¶
AppendInt appends the base62 representation of the integer num using StdEncoding, to dst and returns the extended buffer.
func AppendUint ¶
AppendUint appends the base62 representation of the unsigned integer num using StdEncoding, to dst and returns the extended buffer.
func Decode ¶
Decode decodes src using StdEncoding, returns the decoded bytes.
If src contains invalid base62 data, it will return nil and CorruptInputError.
func DecodeString ¶
DecodeString returns the bytes represented by the base62 string src using StdEncoding.
func DecodeToBuf ¶
DecodeToBuf decodes src using StdEncoding, appending the decoded bytes to dst. If dst has not enough capacity, it copies dst and returns the extended buffer.
If src contains invalid base62 data, it will return nil and CorruptInputError.
func EncodeToBuf ¶
EncodeToBuf encodes src using StdEncoding, appending the encoded bytes to dst. If dst has not enough capacity, it copies dst and returns the extended buffer.
func EncodeToString ¶
EncodeToString returns a base62 string representation of src using StdEncoding.
func FormatUint ¶
FormatUint encodes an unsigned integer num to base62 using StdEncoding.
Types ¶
type CorruptInputError ¶
type CorruptInputError int64
func (CorruptInputError) Error ¶
func (e CorruptInputError) Error() string
type Encoding ¶
type Encoding struct {
// contains filtered or unexported fields
}
An Encoding is a radix 62 encoding/decoding scheme, defined by a 62-character alphabet.
func NewEncoding ¶
NewEncoding returns a new Encoding defined by the given alphabet, which must be a 62-byte string that does not contain CR / LF ('\r', '\n').
func (*Encoding) AppendInt ¶
AppendInt appends the base62 representation of the integer num, as generated by FormatInt, to dst and returns the extended buffer.
func (*Encoding) AppendUint ¶
AppendUint appends the base62 representation of the unsigned integer num, as generated by FormatUint, to dst and returns the extended buffer.
func (*Encoding) Decode ¶
Decode decodes src using the encoding enc, returns the decoded bytes.
If src contains invalid base62 data, it will return nil and CorruptInputError.
func (*Encoding) DecodeString ¶
DecodeString returns the bytes represented by the base62 string src.
func (*Encoding) DecodeToBuf ¶
DecodeToBuf decodes src using the encoding enc, appending the decoded bytes to dst. If dst has not enough capacity, it copies dst and returns the extended buffer.
If src contains invalid base62 data, it will return nil and CorruptInputError.
func (*Encoding) EncodeToBuf ¶
EncodeToBuf encodes src using the encoding enc, appending the encoded bytes to dst. If dst has not enough capacity, it copies dst and returns the extended buffer.
func (*Encoding) EncodeToString ¶
EncodeToString returns a base62 string representation of src.
func (*Encoding) FormatUint ¶
FormatUint encodes an unsigned integer num to base62 using the encoding enc.