Crates.io | escapecolors |
lib.rs | escapecolors |
version | 0.9.1 |
source | src |
created_at | 2022-03-15 10:09:51.540073 |
updated_at | 2022-03-15 10:09:51.540073 |
description | Escape Ansi colours (Select Graphic Rendition) from strings |
homepage | https://github.com/naive-coders/rust-escapecolors |
repository | https://github.com/naive-coders/rust-escapecolors |
max_upload_size | |
id | 550397 |
size | 5,791 |
escapecolors
is a rust crate that provides both a binary and a lib to escape colors from a string following ANSI SGR specifications.
echo -e '\E[31mhello\E[7;32min\E[0;4;44mcolors\E[0m' | escapecolors
use ansi_string::AnsiString;
fn main() {
let bytes_with_colors = vec![27,91,51,52,109,72,101,108,108,111,27,91,48,109];
let string_with_colors = String::from_utf8(bytes_with_color).unwrap();
let ansi_string = AnsiString::new(string_with_colors);
println!("Without colors: {}", ansi_string.without_colors);
println!("With colors: {}", ansi_string.original);
}