You are here

public static function Unicode::strlen in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\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.

36 calls to Unicode::strlen()
Color::validateHex in core/lib/Drupal/Component/Utility/Color.php
Validates whether a hexadecimal color value is syntactically correct.
DiffEngine::_line_hash in core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
Returns the whole line if it's small enough, or the MD5 hash otherwise.
Entity::preSave in core/lib/Drupal/Core/Entity/Entity.php
Acts on an entity before the presave hook is invoked.
EntityType::__construct in core/lib/Drupal/Core/Entity/EntityType.php
Constructs a new EntityType.
EntityUser::processStubRow in core/modules/user/src/Plugin/migrate/destination/EntityUser.php
Do as much population of the stub row as we can.

... See full list

File

core/lib/Drupal/Component/Utility/Unicode.php, line 288
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));
  }
}