1 unstable release
0.0.1 | Jul 21, 2019 |
---|
#24 in #inspector
18KB
300 lines
String inspector
Command line utility to inspect unicode strings
How to install
TODO
Usage
cargo run hello world
Example output:
[utf-8]
bytes: 68 65 6c 6c 6f 20 77 6f 72 6c 64
chars: h e l l o w o r l d
hello world
See cargo run -- -h
for detailed usage.
Versioning
This project follows Semantic Versioning.
Contributing
All contributions are welcome, but issues tagged with either of the following are good places to start:
See CONTRIBUTING.md for more details.
License
All code is free to use under the MIT license
lib.rs
:
Utilities for inspecting unicode strings.
Usage
Use DecodedString to wrap a sequence of bytes and a rust-encoding encoding.
let bytes = [65, 66, 67];
let string = string_inspector::DecodedString::decode(&bytes, encoding::all::ISO_8859_2).unwrap();
assert_eq!("ABC", string.to_string());
assert_eq!("\u{1b}[32mA \u{1b}[0m\u{1b}[34mB \u{1b}[0m\u{1b}[32mC \u{1b}[0m", string.format_characters());
assert_eq!("\u{1b}[32m41 \u{1b}[0m\u{1b}[34m42 \u{1b}[0m\u{1b}[32m43 \u{1b}[0m", string.format_bytes());
DecodedString contains a sequence of DecodedCharacters, which retain the original byte representation:
let bytes = [65, 66, 67];
let string = string_inspector::DecodedString::decode(&bytes, encoding::all::ISO_8859_2).unwrap();
assert_eq!(3, string.characters.len());
assert_eq!('A', string.characters[0].character);
assert_eq!(vec![65], string.characters[0].bytes);
Dependencies
~3–11MB
~81K SLoC