function drupal_strlen in Drupal 7
Same name and namespace in other branches
- 4 includes/unicode.inc \drupal_strlen()
- 5 includes/unicode.inc \drupal_strlen()
- 6 includes/unicode.inc \drupal_strlen()
Counts the number of characters in a UTF-8 string.
This is less than or equal to the byte count.
Parameters
$text: The string to run the operation on.
Return value
integer The length of the string.
Related topics
21 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.
File
- includes/
unicode.inc, line 479 - Provides Unicode-related conversions and operations.
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));
}
}