Unicode::truncateBytes

public static Unicode::truncateBytes($string, $len) Truncates a UTF-8-encoded string safely to a number of bytes. If the end position is in the middle of a UTF-8 sequence, it scans backwards until the beginning of the byte sequence. Use this function whenever you want to chop off a string at an unsure location. On the other hand, if you're sure that you're splitting on a character boundary (e.g. after using strpos() or similar), you can safely use substr() instead. Parameters string $string: T

Unicode::ucwords

public static Unicode::ucwords($text) Capitalizes the first character of each word in a UTF-8 string. Parameters string $text: The text that will be converted. Return value string The input $text with each word capitalized. Related topics PHP wrapper functions Functions that are wrappers or custom implementations of PHP functions. File core/lib/Drupal/Component/Utility/Unicode.php, line 377 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component

unicode_requirements

unicode_requirements() Returns Unicode library status and errors. File core/includes/unicode.inc, line 13 Provides Unicode-related conversions and operations. Code function unicode_requirements() { $libraries = array( Unicode::STATUS_SINGLEBYTE => t('Standard PHP'), Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'), Unicode::STATUS_ERROR => t('Error'), ); $severities = array( Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING, Unicode::STATUS_MULTIB

Unicode::ucfirst

public static Unicode::ucfirst($text) Capitalizes the first character of a UTF-8 string. Parameters string $text: The string to convert. Return value string The string with the first character as uppercase. File core/lib/Drupal/Component/Utility/Unicode.php, line 346 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component\Utility Code public static function ucfirst($text) { return static::strtoupper(static::substr($text, 0, 1)) . static::substr

Unicode::validateUtf8

public static Unicode::validateUtf8($text) Checks whether a string is valid UTF-8. All functions designed to filter input should use drupal_validate_utf8 to ensure they operate on valid UTF-8 strings to prevent bypass of the filter. When text containing an invalid UTF-8 lead byte (0xC0 - 0xFF) is presented as UTF-8 to Internet Explorer 6, the program may misinterpret subsequent bytes. When these subsequent bytes are HTML control characters such as quotes or angle brackets, parts of the text tha

Unicode::strtolower

public static Unicode::strtolower($text) Converts a UTF-8 string to lowercase. Parameters string $text: The string to run the operation on. Return value string The string in lowercase. File core/lib/Drupal/Component/Utility/Unicode.php, line 324 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component\Utility Code public static function strtolower($text) { if (static::getStatus() == static::STATUS_MULTIBYTE) { return mb_strtolower($text);

Unicode::strlen

public static Unicode::strlen($text) Counts the number of characters in a UTF-8 string. This is less than or equal to the byte count. Parameters string $text: The string to run the operation on. Return value int The length of the string. File core/lib/Drupal/Component/Utility/Unicode.php, line 283 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component\Utility Code public static function strlen($text) { if (static::getStatus() == static::STATUS

Unicode::strtoupper

public static Unicode::strtoupper($text) Converts a UTF-8 string to uppercase. Parameters string $text: The string to run the operation on. Return value string The string in uppercase. File core/lib/Drupal/Component/Utility/Unicode.php, line 302 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component\Utility Code public static function strtoupper($text) { if (static::getStatus() == static::STATUS_MULTIBYTE) { return mb_strtoupper($text);

Unicode::substr

public static Unicode::substr($text, $start, $length = NULL) Cuts off a piece of a string based on character indices and counts. Follows the same behavior as PHP's own substr() function. Note that for cutting off a string at a known character/substring location, the usage of PHP's normal strpos/substr is safe and much faster. Parameters string $text: The input string. int $start: The position at which to start reading. int $length: The number of characters to read. Return value string The sho

Unicode::truncate

public static Unicode::truncate($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1) Truncates a UTF-8-encoded string safely to a number of characters. Parameters string $string: The string to truncate. int $max_length: An upper limit on the returned string length, including trailing ellipsis if $add_ellipsis is TRUE. bool $wordsafe: If TRUE, attempt to truncate on a word boundary. Word boundaries are spaces, punctuation, and Unicode characters used as word