core/encoding/hex
encoding_hex
Procedures
6decode
decode :: proc(src: []u8, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (dst: []u8, ok: bool)SourceDecodes a hex sequence into a byte slice
Allocates Using Provided Allocator
Inputs:
- dst: The hex sequence decoded into bytes
- src: The
[]byteto be hex-decoded - allocator: (default: context.allocator)
- loc: The caller location for debugging purposes (default: #caller_location)
Returns:
- ok: A bool,
trueif decoding succeeded,falseotherwise
decode_sequence
decode_sequence :: proc(str: string) -> (res: u8, ok: bool)SourceDecodes 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,
trueif decoding succeeded,falseotherwise
encode
encode :: proc(src: []u8, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (res: []u8, err: runtime.Allocator_Error)SourceEncodes a byte slice into a lowercase hex sequence
Allocates Using Provided Allocator
Inputs:
- src: The
[]byteto 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,
.Noneotherwise
encode_into_writer
encode_into_writer :: proc(dst: io.Writer, src: []u8) -> (err: io.Error)SourceEncodes a byte slice as a lowercase hex sequence into an io.Writer
Inputs:
Returns:
- err: An
io.Errorif one occured,.Noneotherwise
encode_upper
encode_upper :: proc(src: []u8, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (res: []u8, err: runtime.Allocator_Error)SourceEncodes a byte slice into an uppercase hex sequence
Allocates Using Provided Allocator
Inputs:
- src: The
[]byteto 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,
.Noneotherwise
encode_upper_into_writer
encode_upper_into_writer :: proc(dst: io.Writer, src: []u8) -> (err: io.Error)SourceEncodes a byte slice as an uppercase hex sequence into an io.Writer
Inputs:
Returns:
- err: An
io.Errorif one occured,.Noneotherwise