Skip to content

std.hex

bytes <-> hex; encodes lowercase (or upper), decodes either case

pub HexError :: errors {
invalid_character,
odd_length,
buffer_too_small,
}
  • invalid_character: not a hex digit
  • odd_length: half a byte at the end
  • buffer_too_small: out too small; nothing written
pub encode :: fn(out: []u8, src: []const u8) -> usize ! HexError

lowercase hex of src into out; returns 2 * src.len

pub encode_upper :: fn(out: []u8, src: []const u8) -> usize ! HexError

encode, uppercase

pub encode_in :: fn(a: *Arena, src: []const u8) -> []u8

lowercase hex of src, in a

pub encode_upper_in :: fn(a: *Arena, src: []const u8) -> []u8

uppercase hex of src, in a

pub digit_value :: fn(c: u8) -> ?u8

value of hex digit c, either case; null if not hex

pub decode :: fn(out: []u8, text: []const u8) -> usize ! HexError

decode text into out; returns text.len / 2; writes nothing on error

pub decode_in :: fn(a: *Arena, text: []const u8) -> []u8 ! HexError

decode text into a