function drupal_strlen

Count the amount of characters in a UTF-8 string. This is less than or equal to the byte count.

Related topics

32 calls to drupal_strlen()
AccountFormController::validate in drupal/core/modules/user/lib/Drupal/user/AccountFormController.php
Overrides Drupal\Core\Entity\EntityFormController::submit().
Color::validateHex in drupal/core/lib/Drupal/Core/Utility/Color.php
Validates whether a hexadecimal color value is syntatically correct.
DrupalDiffInline::process_chunk in drupal/core/lib/Drupal/Component/Diff/DiffEngine.php
Merge chunk segments between tag delimiters.
DrupalDiffInline::render in drupal/core/lib/Drupal/Component/Diff/DiffEngine.php
Render differences inline using HTML markup.
drupal_html_to_text in drupal/core/includes/mail.inc
Transforms an HTML string into plain text, preserving its structure.

... See full list

File

drupal/core/includes/unicode.inc, line 397

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