Expand description
This project is a library for converting between different Ascii representations in the Rust language. This is made for Rust programs that need to convert an ascii value. This library has methods for converting any of the supported representations to another.
each supported ascii representation has it’s type listed below:
-
Binrary =
Vec<u32>
. -
Decimals =
Vec<u8>
. -
Characters =
String
. -
Hexadecimals =
Vec<String>
.
Each method uses the Result
enum for the return type so this will need to be unwrapped to get the actual value.
An example of how best to deal with the Results enum is below:
use ascii_converter::*;
let input = vec![72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33];
match decimals_to_string(&input){
Ok(num) => println!("* Output: {}", num),
Err(e) => println!("* Error: {}", e),
};
Functions§
- binary_
to_ decimal - This function takes in binary numbers and will return the decimal version.
- binary_
to_ hexadecimal - This function changes the binary number passed into a hexadecimal value.
- binary_
to_ string - This function returns a string made from the binary values passed to it.
- decimal_
to_ hexadecimal - This function is passed decimal numbers and it then returns the hexadecimal representation.
- decimals_
to_ binary - This function returns a binary representations of decimal numbers
- decimals_
to_ string - This function takes in Decimal numbers and will return the string they represent
- hexadecimal_
to_ binary - This function takes in a hexadecimal number then returns the binary version.
- hexadecimal_
to_ decimal - This function takes a hexadecimal number and returns the decimal number.
- hexadecimal_
to_ string - This function returns a hexadecimal number’s string representation.
- string_
to_ binary - This function returns the binary numbers of each letter passed in.
- string_
to_ decimals - This function returns a string’s decimal values
- string_
to_ hexadecimal - This function returns a hexadecimal that represents the string input.