function drupal_strlen

7 unicode.inc drupal_strlen($text)

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

Related topics

20 calls to drupal_strlen()
DrupalHtmlToTextTestCase::testVeryLongLineWrap in modules/simpletest/tests/mail.test
Tests that drupal_html_to_text() wraps before 1000 characters.
drupal_html_to_text in includes/mail.inc
Transforms an HTML string into plain text, preserving its structure.
field_create_field in modules/field/field.crud.inc
Creates a field.
hook_field_validate in modules/field/field.api.php
Validate this module's field data.
list_allowed_values_setting_validate in modules/field/modules/list/list.module
Element validate callback; check that the entered values are valid.

... See full list

File

includes/unicode.inc, line 438

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));
  }
}