stri_length: Count the Number of Characters

Description Usage Arguments Details Value See Also Examples

Description

This function returns the number of code points in each string.

Usage

1

Arguments

str

character vector

Details

Note that the number of code points is not the same as the 'width' of the string when printed on the screen.

If a given string is in UTF-8 and has not been properly Unicode normalized (e.g. by stri_enc_nfc), this number may sometimes be misleading.

Missing values are handled properly, as opposed to the built-in nchar function. For 'byte' encodings we get, as usual, an error.

Value

Returns an integer vector of the same length as str.

See Also

Other length: stri_isempty; stri_numbytes

Examples

1
2
3
4
5
6
7
8
stri_length(LETTERS)
stri_length(c('abc','123','\u0105\u0104'))
stri_length('\u0105') # length is equal to one, but...
stri_numbytes('\u0105') # just like here
## Not run: 
stri_length(stri_enc_nfkd('\u0105')) # ...two code points (!)

## End(Not run)

stringi documentation built on May 2, 2019, 4:54 p.m.