1 unstable release
0.9.1 | Mar 15, 2022 |
---|
#4 in #csi
6KB
98 lines
escapecolors
escapecolors
is a rust crate that provides both a binary and a lib to escape colors from a string following ANSI SGR specifications.
Usage
As a binary:
echo -e '\E[31mhello\E[7;32min\E[0;4;44mcolors\E[0m' | escapecolors
As a lib:
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);
}