Function ascii_converter::decimal_to_hexadecimal
source · [−]Expand description
This function is passed decimal numbers and it then returns the hexadecimal representation.
Takes in a Vec<u8>
where each value is a ascii values decimal number then will convert that to hexadecimal numbers which are returned as Vec<String>
.
If a number passed in is above 126
an error will be thrown.
Example
use ascii_converter::*;
let input = vec![72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33];
let expected = vec![
"48".to_string(),
"65".to_string(),
"6C".to_string(),
"6C".to_string(),
"6F".to_string(),
"20".to_string(),
"77".to_string(),
"6F".to_string(),
"72".to_string(),
"6C".to_string(),
"64".to_string(),
"21".to_string()
];
assert_eq!(decimal_to_hexadecimal(&input).unwrap(), expected);