Skip to main content

decode_pair

Function decode_pair 

pub const fn decode_pair(hi: u8, lo: u8) -> Option<u8>
Expand description

Decode a %XX-style hex pair to its byte value, or None if either nibble is not a valid hex digit.

use rama_utils::hex::decode_pair;
assert_eq!(decode_pair(b'C', b'3'), Some(0xC3));
assert_eq!(decode_pair(b'a', b'9'), Some(0xA9));
assert_eq!(decode_pair(b'Z', b'0'), None);