Function ascii_converter::string_to_binary
source · [−]Expand description
This function returns the binary numbers of each letter passed in.
This function takes each char
of the &str
passed in and converts it to a binary number which is represented
as a u32
. These are then pushed into a Vec<u32>
.
Example
use ascii_converter::*;
let expected = vec![1001000, 1100101, 1101100, 1101100, 1101111, 100000, 1110111, 1101111, 1110010, 1101100, 1100100, 100001];
assert_eq!(string_to_binary(&"Hello world!").unwrap(), expected);