nchar_sgr: Control Sequence Aware Version of nchar

View source: R/nchar.R

nchar_sgrR Documentation

Control Sequence Aware Version of nchar

Description

These functions are deprecated in favor of the nchar_ctl and nzchar_ctl.

Usage

nchar_sgr(
  x,
  type = "chars",
  allowNA = FALSE,
  keepNA = NA,
  warn = getOption("fansi.warn", TRUE)
)

nzchar_sgr(x, keepNA = NA, warn = getOption("fansi.warn", TRUE))

Arguments

x

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

type

character(1L) partial matching c("chars", "width", "graphemes"), although types other than "chars" only work correctly with R >= 3.2.2. See ?nchar.

allowNA

logical: should NA be returned for invalid multibyte strings or "bytes"-encoded strings (rather than throwing an error)?

keepNA

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".

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

Like base::nchar, with Control Sequences excluded.


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