Function ascii_converter::string_to_hexadecimal[][src]

pub fn string_to_hexadecimal(txt: String) -> Result<Vec<String>, String>
Expand description

This function returns a hexadecimal that represents the string input.

Takes in a String and will convert each character to its hexadecimal number. the output is returned in a Vec<String>.

If the input string contains a character not found in the ascii table an error will be thrown.

Example


use ascii_converter::*;
 
let input = "Hello World!".to_string();

let expected = vec![
   "48".to_string(),
   "65".to_string(),
   "6C".to_string(),
   "6C".to_string(),
   "6F".to_string(),
   "20".to_string(),
   "57".to_string(),
   "6F".to_string(),
   "72".to_string(),
   "6C".to_string(),
   "64".to_string(),
   "21".to_string()
   ];
 
assert_eq!(string_to_hexadecimal(input).unwrap(), expected);