base128

package
v0.0.0-...-ddee7fb Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package base128 implements base128 encoding and decoding.

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

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

func Decode

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

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

DecodeString returns the bytes represented by the base128 string s.

func DecodedLen

func DecodedLen(encLen int) int

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

func Encode

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

func EncodeToString(src []byte) string

EncodeToString returns the base128 encoding of src.

func EncodedLen

func EncodedLen(dataLen int) int

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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