suve

awful: function: str-len

Declaration

int :str-len ( string $STR )

Summary

Returns length of given string. For UTF-8 strings, this will be the number of Unicode codepoints present in the string. For ASCII strings, this will simply be the number of bytes.

Example

# :str-len example
:set &UTF u''
:readln &UTF

:set &STR s''
:set &STR $UTF

:writeln s'$UTF = ' $UTF
:writeln s'UTF-8 length: ' (:str-len $UTF) s' codepoints.'
:writeln s'ASCII length: ' (:str-len $STR) s' characters.'

wikipage modified on 2014/0601/2317