On this page
function drupal_strlen
drupal_strlen($text)
Counts the number of characters in a UTF-8 string.
This is less than or equal to the byte count.
Parameters
$text: The string to run the operation on.
Return value
integer The length of the string.
Related topics
File
- includes/unicode.inc, line 479
- Provides Unicode-related conversions and operations.
Code
function drupal_strlen($text) {
global $multibyte;
if ($multibyte == UNICODE_MULTIBYTE) {
return mb_strlen($text);
}
else {
// Do not count UTF-8 continuation bytes.
return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!unicode.inc/function/drupal_strlen/7.x