Crates.io | ascii_converter |
lib.rs | ascii_converter |
version | 0.3.0 |
source | src |
created_at | 2021-07-03 22:50:06.107012 |
updated_at | 2022-06-05 15:00:48.315511 |
description | A library for converting between different ascii representations |
homepage | https://github.com/BrandonC98/ascii_converter |
repository | https://github.com/BrandonC98/ascii_converter |
max_upload_size | |
id | 418362 |
size | 47,100 |
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.
Currently supported representations
Full Documentation for this library can be found here
Add this to your projects Cargo.toml:
[dependencies]
ascii_converter = "0.3.0"
This library consists of several functions that follow the same simplistic convention, input the data and the new representation is returned.
below is a program that converts text to binary and decimal. this code can be found in the examples/conversion.rs
use ascii_converter::*;
use std::io::*;
fn main() {
let mut name = String::new();
print!("Enter name: ");
stdout().flush().expect("unable to flush buffer");
//reads user input and assigns it to the name variable
stdin().read_line(&mut name).unwrap();
let name = name.trim();
//outputs the binary representation
println!("* {} in Binary: {:?}", name, string_to_binary(&name).unwrap());
//outputs the decimal representation
println!("* {} in Decimal: {:?}", name, string_to_decimals(&name).unwrap());
}
Running the code above will give you the output below