luci: Index | Files

package base128

import ""

Package base128 implements base128 encoding and decoding.

Encoded results are UTF8-safe, and will retain the same memcmp sorting properties of the input data.


Package Files



var (
    // ErrLength is returned from the Decode* methods if the input has an
    // impossible length.
    ErrLength = errors.New("base128: invalid length base128 string")

    // ErrBit is returned from the Decode* methods if the input has a byte with
    // the high-bit set (e.g. 0x80). This will never be the case for strings
    // produced from the Encode* methods in this package.
    ErrBit = errors.New("base128: high bit set in base128 string")

func Decode Uses

func Decode(dst, src []byte) (int, error)

Decode decodes src into DecodedLen(len(src)) bytes, returning the actual number of bytes written to dst.

If Decode encounters invalid input, it returns an error describing the failure.

func DecodeString Uses

func DecodeString(s string) ([]byte, error)

DecodeString returns the bytes represented by the base128 string s.

func DecodedLen Uses

func DecodedLen(encLen int) int

DecodedLen returns the number of bytes `encLen` encoded bytes decodes to.

func Encode Uses

func Encode(dst, src []byte) int

Encode encodes src into EncodedLen(len(src)) bytes of dst. As a convenience, it returns the number of bytes written to dst, but this value is always EncodedLen(len(src)).

Encode implements base128 encoding.

func EncodeToString Uses

func EncodeToString(src []byte) string

EncodeToString returns the base128 encoding of src.

func EncodedLen Uses

func EncodedLen(dataLen int) int

EncodedLen returns the number of bytes that `dataLen` bytes will encode to.

Package base128 imports 1 packages (graph). Updated 2021-01-25. Refresh now. Tools for package owners.