On this page
public static function Unicode::strlen
public static Unicode::strlen($text)
Counts the number of characters in a UTF-8 string.
This is less than or equal to the byte count.
Parameters
string $text: The string to run the operation on.
Return value
int The length of the string.
File
- core/lib/Drupal/Component/Utility/Unicode.php, line 283
Class
- Unicode
- Provides Unicode-related conversions and operations.
Namespace
Drupal\Component\UtilityCode
public static function strlen($text) {
if (static::getStatus() == static::STATUS_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/core!lib!Drupal!Component!Utility!Unicode.php/function/Unicode::strlen/8.1.x