#ascii #hex #binary #convert-binary #converter #binary-representation #convert-hex

ascii_converter

A library for converting between different ascii representations

8 releases

0.3.0 Jun 5, 2022
0.2.3 May 11, 2022
0.2.2 Apr 16, 2022
0.2.1 Sep 14, 2021
0.1.2 Jul 4, 2021

#928 in Text processing

Download history 51/week @ 2023-12-17 14/week @ 2023-12-24 14/week @ 2023-12-31 80/week @ 2024-01-07 54/week @ 2024-01-14 35/week @ 2024-01-21 49/week @ 2024-01-28 52/week @ 2024-02-04 41/week @ 2024-02-11 122/week @ 2024-02-18 157/week @ 2024-02-25 71/week @ 2024-03-03 135/week @ 2024-03-10 46/week @ 2024-03-17 68/week @ 2024-03-24 81/week @ 2024-03-31

336 downloads per month
Used in 3 crates

MIT license

28KB
362 lines

Ascii Converter


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.

Currently supported representations

  • Binary
  • Decimal
  • Characters
  • Hexadecimals

Full Documentation for this library can be found here


Installation

Add this to your projects Cargo.toml:

[dependencies]
ascii_converter = "0.3.0"

Usage

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

Output


License

MIT

No runtime deps