escapecolors

Crates.ioescapecolors
lib.rsescapecolors
version0.9.1
sourcesrc
created_at2022-03-15 10:09:51.540073
updated_at2022-03-15 10:09:51.540073
descriptionEscape Ansi colours (Select Graphic Rendition) from strings
homepagehttps://github.com/naive-coders/rust-escapecolors
repositoryhttps://github.com/naive-coders/rust-escapecolors
max_upload_size
id550397
size5,791
Pierre-Jean Baraud (pierre-jean)

documentation

README

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);
}
Commit count: 5

cargo fmt