Function ascii_converter::string_to_decimals [−][src]
pub fn string_to_decimals(text: &str) -> Result<Vec<u8>, String>
Expand description
This function returns a string’s decimal values
takes a string and finds the decimal assciated with that character according to the Ascii table.
each decimal is pushed into a Vec<u8>
.
charcters inside the string should only be in the ascii range of 32 - 126
. any other
character will cause an error.
example of unsupported characters: £
, ☢️
, Æ
Example
use ascii_converter::*; let expected = vec![72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]; assert_eq!(string_to_decimals("Hello world!").unwrap(), expected);