strlen - length of string

SYNOPSIS

<strlen $str [$mode]>


DESCRIPTION
strlen returns the (integer) character length of each string value of $str.

The optional $mode argument is a stringcomparemode-style (here) compare mode to use; the default is the current apicp stringcomparemode. The $mode values are used in the same order as $str values. Currently the only pertinent $mode flag is "iso-8859-1", which determines whether to interpret text as ISO-8859-1 or UTF-8. This can alter how many characters long the string appears to be, as UTF-8 characters are variable-byte-sized, whereas ISO-8859-1 characters are always mono-byte. The $mode argument was added in version 6.


DIAGNOSTICS
strlen returns the character (not necessarily byte) length of each string value of $str, according to stringcomparemode $mode.


EXAMPLE

<strlen 123>

The return value in $ret would be 3.


CAVEATS
The strlen function was added Feb. 5 1997.

The length returned is the number of characters (not bytes) of the string value of the argument(s), i.e. values are cast to varchar first, and the length stops with the first nul (U+0000) character. For the full size of varbyte values (that may contain nuls), use the varinfo function's size action.

The number of characters returned may vary with $mode, i.e. whether "iso-8859-1" is set or not.


SEE ALSO
varinfo


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.