drupal_strlen

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.

Related topics

▾ 15 functions call drupal_strlen()

drupal_html_to_text in includes/mail.inc
Transform an HTML string into plain text, preserving the structure of the markup. Useful for preparing the body of a node to be sent by e-mail.
field_create_field in modules/field/field.crud.inc
Create a field.
field_ui_existing_field_options in modules/field_ui/field_ui.admin.inc
Return an array of existing field to be added to a bundle.
hook_field_validate in modules/field/field.api.php
Define custom validate behavior for this module's field types.
menu_contextual_links in includes/menu.inc
Retrieve contextual links for a system object based on registered local tasks.
search_expand_cjk in modules/search/search.module
Basic CJK tokenizer. Simply splits a string into consecutive, overlapping sequences of characters ('minimum_word_size' long).
search_index in modules/search/search.module
Update the full-text search index for a particular item.
taxonomy_form_vocabulary_validate in modules/taxonomy/taxonomy.admin.inc
Validation handler for the vocabulary form.
template_preprocess_username in includes/theme.inc
Preprocess variables for theme_username().
text_field_validate in modules/field/modules/text/text.module
Implement hook_field_validate().
text_summary in modules/field/modules/text/text.module
Generate a trimmed, formatted version of a text field value.
truncate_utf8 in includes/unicode.inc
Truncate a UTF-8-encoded string safely to a number of characters.
user_account_form_validate in modules/user/user.module
Form validation handler for user_account_form().
user_validate_name in modules/user/user.module
Verify the syntax of the given name.
_form_validate in includes/form.inc
Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.

Code

includes/unicode.inc, line 400

<?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));
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.