Back to godoc.org

Package base128

v0.0.0-...-d4769a7
Latest Go to latest

The latest major version is .

Published: Aug 1, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

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

Variables

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

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier