strip_sgr: Strip Control Sequences

View source: R/sgr.R

strip_sgrR Documentation

Strip Control Sequences

Description

This function is deprecated in favor of the strip_ctl. It strips CSI SGR and OSC hyperlink sequences.

Usage

strip_sgr(x, warn = getOption("fansi.warn", TRUE))

Arguments

x

a character vector or object that can be coerced to such.

warn

TRUE (default) or FALSE, whether to warn when potentially problematic Control Sequences are encountered. These could cause the assumptions fansi makes about how strings are rendered on your display to be incorrect, for example by moving the cursor (see ?fansi). At most one warning will be issued per element in each input vector. Will also warn about some badly encoded UTF-8 strings, but a lack of UTF-8 warnings is not a guarantee of correct encoding (use validUTF8 for that).

Value

character vector of same length as x with ANSI escape sequences stripped

Examples

## convenience function, same as `strip_ctl(ctl=c('sgr', 'url'))`
string <- "hello\033k\033[45p world\n\033[31mgoodbye\a moon"
strip_sgr(string)

fansi documentation built on May 29, 2024, 4:03 a.m.