drupal_strlen

Definition

drupal_strlen($text)
drupal/includes/unicode.inc, line 394

Description

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

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("/[\x80-\xBF]/", '', $text));
  }
}