encoding.hex
fn decode #
fn decode(s string) ![]u8
decode converts a hex string into an array of bytes. The expected input format is 2 ASCII characters for each output byte. If the provided string length is not a multiple of 2, the first digit is decoded as if an implicit 0 preceded it. An optional 0x or 0X prefix is accepted.
fn encode #
fn encode(bytes []u8, params EncodeParams) string
encode converts an array of bytes into a string of ASCII hex bytes. The output will always be a string whose length will be a multiple of 2. If EncodeParams.uppercase is set, the output hex characters are emitted in uppercase. If EncodeParams.with_prefix is non-empty, the output string is prefixed with the provided string.
struct EncodeParams #
struct EncodeParams {
pub mut:
uppercase bool
with_prefix string
}
EncodeParams configures optional output formatting for encode.
If uppercase is set, encode emits A-F instead of a-f. If with_prefix is non-empty, encode prepends that exact string.