std.encoding
std.encoding: bytes as text, the other way from std.text: base64 and base16 (hex) of RFC 4648. Encoding gives new memory from the allocator (free it with `alloc.free`). Decoding checks all of its input and gives an error, never a partial result.
InputError
pub error InputError { InvalidCharacter, InvalidLength }
DecodeError
pub error DecodeError = InputError || AllocError
base64Encode
pub fn base64Encode(alloc: Allocator, data: []u8) AllocError![]mut u8
The base64 text of `data` (RFC 4648 section 4: `+` and `/`), padded with `=` to a multiple of 4 bytes.
base64Decode
pub fn base64Decode(alloc: Allocator, text: []u8) DecodeError![]mut u8
The bytes of base64 `text` (RFC 4648 section 4). The text must be padded; a byte outside the alphabet gives `InvalidCharacter` and a length that is not a multiple of 4, `InvalidLength`. Non-zero trailing bits in the last symbol (RFC 4648 section 3.5) give `InvalidCharacter`.
base64UrlEncode
pub fn base64UrlEncode(alloc: Allocator, data: []u8) AllocError![]mut u8
The URL-safe base64 text of `data` (RFC 4648 section 5: `-` and `_`), without padding.
base64UrlDecode
pub fn base64UrlDecode(alloc: Allocator, text: []u8) DecodeError![]mut u8
The bytes of URL-safe base64 `text` (RFC 4648 section 5), with or without its `=` padding. Errors as in `base64Decode`.
hexEncode
pub fn hexEncode(alloc: Allocator, data: []u8) AllocError![]mut u8
The lowercase hex text of `data` (RFC 4648 section 8), two characters per byte.
hexDecode
pub fn hexDecode(alloc: Allocator, text: []u8) DecodeError![]mut u8
The bytes of hex `text`, in either case. An odd length gives `InvalidLength`, a character that is not a hex digit `InvalidCharacter`.