drupal_strlen

  1. drupal
    1. 4.7
    2. 5
    3. 6 unicode.inc
    4. 7 unicode.inc
Versions
4.7 – 7 drupal_strlen($text)

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

▾ 4 functions call drupal_strlen()

search_expand_cjk in modules/search.module
Basic CJK tokenizer. Simply splits a string into consecutive, overlapping sequences of characters ('minimum_word_size' long).
search_index in modules/search.module
Update the full-text search index for a particular item.
theme_username in includes/theme.inc
Format a username.
_search_parse_query in modules/search.module
Helper function for search_parse_query();

Code

includes/unicode.inc, line 347

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