public static 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.

4 calls to Unicode::strlen()
Color::validateHex in drupal/core/lib/Drupal/Core/Utility/Color.php
Validates whether a hexadecimal color value is syntatically correct.
drupal_strlen in drupal/core/includes/unicode.inc
Counts the number of characters in a UTF-8 string.
Unicode::truncate in drupal/core/lib/Drupal/Component/Utility/Unicode.php
Truncates a UTF-8-encoded string safely to a number of characters.
UnicodeTest::testStrlen in drupal/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
Tests Unicode::strlen().

File

drupal/core/lib/Drupal/Component/Utility/Unicode.php, line 250
Contains \Drupal\Component\Utility\Unicode.

Class

Unicode
Provides Unicode-related conversions and operations.

Namespace

Drupal\Component\Utility

Code

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("", '', $text));
  }
}