Documentation
¶
Overview ¶
Package encoding provides low-level encoding utilities with no dependencies. This is the foundational package for ID encoding used throughout LCI.
Base-63 Alphabet: A-Z (0-25), a-z (26-51), 0-9 (52-61), _ (62) This provides ~6 character IDs for typical projects (vs ~16 for hex).
Index ¶
- Constants
- Variables
- func Base63CharToValue(c rune) (uint64, error)
- func Base63Decode(encoded string) (uint64, error)
- func Base63Encode(value uint64) string
- func Base63EncodeNoZero(value uint64) string
- func Base63IsValid(encoded string) bool
- func Base63ValueToChar(val uint64) byte
- func PackUint32Pair(lower, upper uint32) uint64
- func UnpackUint32Pair(packed uint64) (lower, upper uint32)
Constants ¶
const ( Base63 = 63 Alphabet63 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" )
Base-63 encoding constants
Variables ¶
var ( ErrEmptyString = errors.New("empty encoded string") ErrInvalidChar = errors.New("invalid character in encoded string") ErrOverflow = errors.New("decoded value overflow") )
Common errors for encoding operations
Functions ¶
func Base63CharToValue ¶
Base63CharToValue converts a character to its base-63 numeric value (0-62).
func Base63Decode ¶
Base63Decode decodes a base-63 string to a uint64 value. Returns error for empty strings or invalid characters.
func Base63Encode ¶
Base63Encode encodes a uint64 value to a base-63 string. Returns "A" for zero (minimum non-empty encoding).
func Base63EncodeNoZero ¶
Base63EncodeNoZero encodes a uint64 value to a base-63 string. Returns empty string for zero value (used for composite IDs where 0 means "none").
func Base63IsValid ¶
Base63IsValid checks if a string is a valid base-63 encoded value.
func Base63ValueToChar ¶
Base63ValueToChar converts a base-63 numeric value (0-62) to its character. Panics if value > 62 (internal error, should never happen with valid input).
func PackUint32Pair ¶
PackUint32Pair packs two uint32 values into a single uint64. lower goes into lower 32 bits, upper goes into upper 32 bits.
func UnpackUint32Pair ¶
UnpackUint32Pair unpacks a uint64 into two uint32 values. Returns (lower 32 bits, upper 32 bits).
Types ¶
This section is empty.