Skip to main content

37  hex standard library

The hex module provides RFC 4648 Section 8 Base16 (hexadecimal) encoding and case-insensitive decoding with diagnostic column offsets on malformed input.

#use hex
#use io

enc = hex::encode("Edva")
io::out $ enc
hex::decode(enc) | dec => io::out $ dec

37.1 Function catalog

Symbol / Function Signature Description
hex::encode(s) String => String Encodes raw bytes of s into lowercase hexadecimal (2 * ?s ASCII bytes)
hex::encode_upper(s) String => String Encodes raw bytes of s into uppercase hexadecimal (2 * ?s ASCII bytes)
hex::decode(s) String => < String | Error > Decodes a case-insensitive hexadecimal string into raw bytes, or returns an Error on odd length or non-hex bytes