std::encoding::hexHexadecimal encoding and decoding.
Encode binary data to hexadecimal strings (lowercase or uppercase) and decode hexadecimal strings back to binary data.
import std::encoding::hex;
fn main() {
let data: bytes = bytes::new();
data.push(0xDE);
data.push(0xAD);
let s = hex.encode(data);
println(s); // "dead"
let back = hex.decode(s);
println(back.len()); // 2
}
encodeEncode binary data to a lowercase hex string.
encode_upperEncode binary data to an uppercase hex string.
decodeDecode a hex string to binary data.
Returns an empty bytes buffer if the input is not valid hex.
encode_implEncode binary data to a hex string, optionally uppercase.
nibble_to_charConvert a 4-bit nibble (0โ15) to its ASCII hex character code.
hex_char_to_nibbleConvert a single hex character to its 4-bit nibble value, or -1 if invalid.