has_ctl {fansi} | R Documentation |
Check for Presence of Control Sequences
Description
has_ctl
checks for any Control Sequence. You can check for different
types of sequences with the ctl
parameter. Warnings are only emitted for
malformed CSI or OSC sequences.
Usage
has_ctl(x, ctl = "all", warn = getOption("fansi.warn", TRUE), which)
Arguments
x |
a character vector or object that can be coerced to such. |
ctl |
character, which Control Sequences should be treated
specially. Special treatment is context dependent, and may include
detecting them and/or computing their display/character width as zero. For
the SGR subset of the ANSI CSI sequences, and OSC hyperlinks,
|
warn |
TRUE (default) or FALSE, whether to warn when potentially
problematic Control Sequences are encountered. These could cause the
assumptions |
which |
character, deprecated in favor of |
Value
logical of same length as x
; NA values in x
result in NA values
in return
See Also
?fansi
for details on how Control Sequences are
interpreted, particularly if you are getting unexpected results,
unhandled_ctl
for detecting bad control sequences.
Examples
has_ctl("hello world")
has_ctl("hello\nworld")
has_ctl("hello\nworld", "sgr")
has_ctl("hello\033[31mworld\033[m", "sgr")