col_nchar {crayon} | R Documentation |
Count number of characters in an ANSI colored string
Description
This is a color-aware counterpart of base::nchar()
,
which does not do well, since it also counts the ANSI control
characters.
Usage
col_nchar(x, ...)
Arguments
x |
Character vector, potentially ANSO styled, or a vector to be coarced to character. |
... |
Additional arguments, passed on to |
Value
Numeric vector, the length of the strings in the character vector.
See Also
Other ANSI string operations:
col_align()
,
col_strsplit()
,
col_substr()
,
col_substring()
Examples
str <- paste(
red("red"),
"default",
green("green")
)
cat(str, "\n")
nchar(str)
col_nchar(str)
nchar(strip_style(str))
[Package crayon version 1.5.3 Index]