Crate ascii_converter

Source
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.