| sf_nchar {stringfish} | R Documentation |
Counts the number of characters in a character vector
sf_nchar(x, type = "chars")
x |
A character vector |
type |
The type of counting to perform ("chars" or "bytes", default: "chars") |
Returns the number of characters per string. The type of counting only matters for UTF-8 strings, where a character can be represented by multiple bytes.
An integer vector of the number of characters
nchar
x <- "fa\xE7ile" Encoding(x) <- "latin1" x <- sf_iconv(x, "latin1", "UTF-8")