Encoding
tyrus:encoding keeps string in UTF-8 and exposes explicit conversion at data boundaries. Import utf8 for UTF-8 bytes, utf16 for UTF-16 code units or little-endian and big-endian byte sequences, hex for canonical lowercase hexadecimal byte encoding, base64 and base64Url for standard or URL-safe base64, base32 for canonical uppercase base32, and radix for integer formatting and parsing in bases 2, 8, 10, and 16. Strict decoders and radix parsing return Result<..., EncodingError>, which callers inspect with match or propagate with ?; encoders, radix.format, and the decodeLossy, decodeLELossy, and decodeBELossy decoders are infallible, and the lossy decoders replace malformed input with U+FFFD.
API
- UTF-8:
encode, strictdecode, and recoverydecodeLossy. - UTF-16: code units, explicit LE/BE byte order, strict decoders, and lossy decoders.
- Hexadecimal: canonical lowercase encoding and strict decoding.
- Base64: standard
+/alphabet with mandatory padding and strictly canonical decoding. - Base64Url: unpadded URL-safe
-_alphabet and strictly canonical decoding. - Base32: canonical uppercase encoding with padding and strictly canonical decoding.
- Radix: integer formatting and parsing in bases 2, 8, 10, and 16.
- EncodingError: the error payload returned by strict decoders and radix parsing.
