std/hex
Hex encoding and decoding.
milo
from "std/hex" import { Hex }Example
milo
let encoded = Hex.encode("hello")
print(encoded) // 68656c6c6f
let decoded = Hex.decode(encoded)!
print(decoded) // hello
print(Hex.decode("66 6f").isErr()) // trueAPI reference
Hex
milo
pub struct HexHex namespace — call as Hex.encode(...), Hex.decode(...).
Hex.decode
milo
fn Hex.decode(input: &string): Result<string>Decode a hex string. Case-insensitive, but errs on an odd length or any byte that is not an ASCII hex digit — no whitespace, "0x" prefix, or separators.
Hex.encode
milo
fn Hex.encode(input: &string): stringEncode each byte as two lowercase hex digits.
Functions
hexChar
milo
pub fn hexChar(val: u8): u8