function Unicode::strlen

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.

Deprecated

in drupal:8.6.0 and is removed from drupal:9.0.0. Use mb_strlen() instead.

See also

https://www.drupal.org/node/2850048

1 call to Unicode::strlen()
UnicodeTest::testStrlen in core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
Tests multibyte strlen.

File

core/lib/Drupal/Component/Utility/Unicode.php, line 269

Class

Unicode
Provides Unicode-related conversions and operations.

Namespace

Drupal\Component\Utility

Code

public static function strlen($text) {
    @trigger_error('\\Drupal\\Component\\Utility\\Unicode::strlen() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use mb_strlen() instead. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
    return mb_strlen($text);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.