Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[no_mangle]
- pub fn hextobin1(ch: u8) -> u8 {
- match ch {
- b'0' => 0,
- b'1' => 1,
- b'2' => 2,
- b'3' => 3,
- b'4' => 4,
- b'5' => 5,
- b'6' => 6,
- b'7' => 7,
- b'8' => 8,
- b'9' => 9,
- b'a' | b'A' => 10,
- b'b' | b'B' => 11,
- b'c' | b'C' => 12,
- b'd' | b'D' => 13,
- b'e' | b'E' => 14,
- b'f' | b'F' => 15,
- _ => 16,
- }
- }
- #[no_mangle]
- pub fn hextobin2(ch: u8) -> u8 {
- match ch {
- b'0'..=b'9' => ch - b'0',
- b'a'..=b'f' => ch - b'a' + 10,
- b'A'..=b'F' => ch - b'A' + 10,
- _ => 16,
- }
- }
Add Comment
Please, Sign In to add comment