Unicode::STATUS_SINGLEBYTE

Indicates that standard PHP (emulated) unicode support is being used. File core/lib/Drupal/Component/Utility/Unicode.php, line 77 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component\Utility Code const STATUS_SINGLEBYTE = 0;

Unicode::strcasecmp

public static Unicode::strcasecmp($str1, $str2) Compares UTF-8-encoded strings in a binary safe case-insensitive manner. Parameters string $str1: The first string. string $str2: The second string. Return value int Returns < 0 if $str1 is less than $str2; > 0 if $str1 is greater than $str2, and 0 if they are equal. File core/lib/Drupal/Component/Utility/Unicode.php, line 583 Class Unicode Provides Unicode-related conversions and operations. Namespace Drupal\Component\Utility Cod

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::strpos

public static Unicode::strpos($haystack, $needle, $offset = 0) Finds the position of the first occurrence of a string in another string. Parameters string $haystack: The string to search in. string $needle: The string to find in $haystack. int $offset: If specified, start the search at this number of characters from the beginning (default 0). Return value int|false The position where $needle occurs in $haystack, always relative to the beginning (independent of $offset), or FALSE if not found.

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::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

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::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