Build Status crates.io

A crate for stripping ANSI escape sequences from byte sequences.

This can be used to take output from a program that includes escape sequences and write it somewhere that does not easily support them, such as a log file.

Examples

The strip function accepts bytes and returns a Vec of bytes with ANSI escape sequences removed.

```rust extern crate stripansiescapes;

use std::io::{self, Write};

fn work() -> io::Result<()> { let byteswithcolors = b"\x1b[32mfoo\x1b[m bar"; let plainbytes = stripansiescapes::strip(&byteswithcolors)?; io::stdout().writeall(&plain_bytes)?; Ok(()) }

fn main() { work().unwrap(); } ```

For writing directly to a writer, the Writer struct may be preferable.

```rust extern crate stripansiescapes;

use std::io::{self, Write}; use stripansiescapes::Writer;

fn work() -> io::Result<()> { let byteswithcolors = b"\x1b[32mfoo\x1b[m bar"; let mut writer = Writer::new(io::stdout()); // Only foo bar will be written to stdout writer.writeall(byteswith_colors)?; Ok(()) }

fn main() { work().unwrap(); } ```

License

Licensed under either of

at your option.