These functions are deprecated in favor of the nchar_ctl
and
nzchar_ctl
.
nchar_sgr(
x,
type = "chars",
allowNA = FALSE,
keepNA = NA,
warn = getOption("fansi.warn", TRUE)
)nzchar_sgr(x, keepNA = NA, warn = getOption("fansi.warn", TRUE))
Like base::nchar
, with Control Sequences excluded.
a character vector or object that can be coerced to such.
character(1L) partial matching
c("chars", "width", "graphemes")
, although types other than "chars" only
work correctly with R >= 3.2.2. See ?nchar
.
logical: should NA
be returned for invalid
multibyte strings or "bytes"
-encoded strings (rather than
throwing an error)?
logical: should NA
be returned when
x
is NA
? If false, nchar()
returns
2
, as that is the number of printing characters used when
strings are written to output, and nzchar()
is TRUE
. The
default for nchar()
, NA
, means to use keepNA = TRUE
unless type
is "width"
.
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).