This is a color-aware counterpart of base::nchar()
,
which does not do well, since it also counts the ANSI control
characters.
ansi_nchar(x, ...)
x | Character vector, potentially ANSO styled, or a vector to be coarced to character. |
---|---|
... | Additional arguments, passed on to |
Numeric vector, the length of the strings in the character vector.
Other ANSI string operations:
ansi_align()
,
ansi_strsplit()
,
ansi_substring()
,
ansi_substr()
#> red default green#> [1] 37ansi_nchar(str)#> [1] 17#> [1] 17