Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 20-Jan-2022 | - | ||||
examples/ | H | 20-Jan-2022 | - | 19 | 15 | |
src/ | H | 20-Jan-2022 | - | 220 | 143 | |
.cargo-checksum.json | H A D | 03-May-2022 | 89 | 1 | 1 | |
Cargo.toml | H A D | 20-Jan-2022 | 989 | 26 | 24 | |
LICENSE-APACHE | H A D | 20-Jan-2022 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | H A D | 20-Jan-2022 | 1 KiB | 26 | 22 | |
README.md | H A D | 20-Jan-2022 | 1.7 KiB | 59 | 40 |
README.md
1[![Build Status](https://travis-ci.org/luser/strip-ansi-escapes.svg?branch=master)](https://travis-ci.org/luser/strip-ansi-escapes) [![crates.io](https://img.shields.io/crates/v/strip-ansi-escapes.svg)](https://crates.io/crates/strip-ansi-escapes) [![](https://docs.rs/strip-ansi-escapes/badge.svg)](https://docs.rs/strip-ansi-escapes) 2 3A crate for stripping ANSI escape sequences from byte sequences. 4 5This can be used to take output from a program that includes escape sequences and write 6it somewhere that does not easily support them, such as a log file. 7 8# Examples 9 10The `strip` function accepts bytes and returns a `Vec` of bytes with ANSI escape sequences removed. 11 12```rust 13extern crate strip_ansi_escapes; 14 15use std::io::{self, Write}; 16 17fn work() -> io::Result<()> { 18 let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar"; 19 let plain_bytes = strip_ansi_escapes::strip(&bytes_with_colors)?; 20 io::stdout().write_all(&plain_bytes)?; 21 Ok(()) 22} 23 24fn main() { 25 work().unwrap(); 26} 27``` 28 29For writing directly to a writer, the `Writer` struct may be preferable. 30 31```rust 32extern crate strip_ansi_escapes; 33 34use std::io::{self, Write}; 35use strip_ansi_escapes::Writer; 36 37fn work() -> io::Result<()> { 38 let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar"; 39 let mut writer = Writer::new(io::stdout()); 40 // Only `foo bar` will be written to stdout 41 writer.write_all(bytes_with_colors)?; 42 Ok(()) 43} 44 45fn main() { 46 work().unwrap(); 47} 48``` 49 50# License 51 52Licensed under either of 53 54 * Apache License, Version 2.0 ([`LICENSE-APACHE`](./LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 55 * MIT license ([`LICENSE-MIT`](./LICENSE-MIT) or http://opensource.org/licenses/MIT) 56 57at your option. 58 59