pub fn strip_str(data: &str) -> StrippedStr<'_> ⓘ
Expand description
Strip ANSI escapes from a &str
, returning the printable content
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.
For non-contiguous data, see StripStr
.
Example
use std::io::Write as _;
let styled_text = "\x1b[32mfoo\x1b[m bar";
let plain_str = anstream::adapter::strip_str(&styled_text).to_string();
assert_eq!(plain_str, "foo bar");