Encoding and decoding of hex-encoded binary, e.g. `0x23` -> `#`.

Collection Info

View Source
Collection
core
Path
encoding/hex
Entries
6

Source Files

Procedures

6

decode #

Source
decode :: proc(src: []u8, allocator := context.allocator, loc := #caller_location) -> (dst: []u8, ok: bool) {…}

Decodes a hex sequence into a byte slice *Allocates Using Provided Allocator* Inputs: - dst: The hex sequence decoded into bytes - src: The `[]byte` to be hex-decoded - allocator: (default: context.allocator) - loc: The caller location for debugging purposes (default: #caller_location) Returns: - ok: A bool, `true` if decoding succeeded, `false` otherwise

decode_sequence #

Source
decode_sequence :: proc(str: string) -> (res: u8, ok: bool) {…}

Decodes the first byte in a hex sequence to a byte Inputs: - str: A hex-encoded `string`, e.g. `"0x23"` Returns: - res: The decoded byte, e.g. `'#'` - ok: A bool, `true` if decoding succeeded, `false` otherwise

encode #

Source
encode :: proc(src: []u8, allocator := context.allocator, loc := #caller_location) -> (res: []u8, err: Allocator_Error) #optional_ok {…}

Encodes a byte slice into a lowercase hex sequence *Allocates Using Provided Allocator* Inputs: - src: The `[]byte` to be hex-encoded - allocator: (default: context.allocator) - loc: The caller location for debugging purposes (default: #caller_location) Returns: - res: The hex-encoded result - err: An optional allocator error if one occured, `.None` otherwise

encode_into_writer #

Source
encode_into_writer :: proc(dst: Stream, src: []u8) -> (err: Error) {…}

Encodes a byte slice as a lowercase hex sequence into an `io.Writer` Inputs: - dst: The `io.Writer` to encode into - src: The `[]byte` to be hex-encoded Returns: - err: An `io.Error` if one occured, `.None` otherwise

encode_upper #

Source
encode_upper :: proc(src: []u8, allocator := context.allocator, loc := #caller_location) -> (res: []u8, err: Allocator_Error) #optional_ok {…}

Encodes a byte slice into an uppercase hex sequence *Allocates Using Provided Allocator* Inputs: - src: The `[]byte` to be hex-encoded - allocator: (default: context.allocator) - loc: The caller location for debugging purposes (default: #caller_location) Returns: - res: The hex-encoded result - err: An optional allocator error if one occured, `.None` otherwise

encode_upper_into_writer #

Source
encode_upper_into_writer :: proc(dst: Stream, src: []u8) -> (err: Error) {…}

Encodes a byte slice as an uppercase hex sequence into an `io.Writer` Inputs: - dst: The `io.Writer` to encode into - src: The `[]byte` to be hex-encoded Returns: - err: An `io.Error` if one occured, `.None` otherwise