diff --git a/core/lib/Drupal/Component/Utility/String.php b/core/lib/Drupal/Component/Utility/String.php index 2a15a12..901c12b 100644 --- a/core/lib/Drupal/Component/Utility/String.php +++ b/core/lib/Drupal/Component/Utility/String.php @@ -162,7 +162,7 @@ public static function upperCase($text) { // Use C-locale for ASCII-only uppercase $text = strtoupper($text); // Case flip Latin-1 accented letters - $text = Unicode::caseFlip('/\xC3[\xA0-\xB6\xB8-\xBE]/', $text); + $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text); return $text; } } @@ -184,7 +184,7 @@ public static function lowerCase($text) { // Use C-locale for ASCII-only lowercase $text = strtolower($text); // Case flip Latin-1 accented letters - $text = Unicode::caseFlip('/\xC3[\x80-\x96\x98-\x9E]/', $text); + $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text); return $text; } } diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php index f0c9d33..e8c2dad 100644 --- a/core/lib/Drupal/Component/Utility/Unicode.php +++ b/core/lib/Drupal/Component/Utility/Unicode.php @@ -286,21 +286,16 @@ public static function mimeHeaderDecode($header) { } /** - * Case flip Latin-1 accented letters. + * Flip U+C0-U+DE to U+E0-U+FD and back. Can be used as preg_replace callback. * - * @param string $text - * The text to case flip. + * @param array $matches + * An array of matches by preg_replace_callback(). * * @return string - * The case flipped text. + * The flipped text. */ - public static function caseFlip($pattern, $text) { - $matches = array(); - $callback = function ($matches) { - // Flip U+C0-U+DE to U+E0-U+FD and back. - return $matches[0][0] . chr(ord($matches[0][1]) ^ 32); - }; - return preg_replace_callback($pattern, $callback , $text); + public static function caseFlip($matches) { + return $matches[0][0] . chr(ord($matches[0][1]) ^ 32); } }