I know how to find the length of a not Unicode string in R.
nchar("ABC")
(thanks everyone who answered the question here: How to find the length of a string in R? ).
But what about Unicode strings?
How to find the length of a string (number of characters in a string) in a Unicode strings? How do I find the length (in bytes) and the number of characters (runes, symbols) in a Unicode string in R?
You can use
nchar
for the number ofcharacters
and for the number ofbytes
:Indeed, in the help, you can find details about how to compute the string size:
If you want to know the number of "symbols" inside the string that may (or may not) contain unicode (i.e. without interpreting the unicode symbol), you can use function
stri_escape_unicode
from packagestringi
: