From ade63094c4ce53b297bf014539bae02a409f48cd Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 25 Jan 2004 05:57:02 +0000 Subject: [PATCH] Using UTF-8 compatible ucfirst/lcfirst --- includes/MessageCache.php | 15 ++++++--------- languages/Language.php | 4 ++++ languages/LanguageUtf8.php | 8 ++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 8224840162..5b95cef31b 100755 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -93,16 +93,17 @@ class MessageCache } function getKeys() { - global $wgAllMessagesEn; + global $wgAllMessagesEn, $wgLang; + $ucfirst = get_class($wgLang) . "::ucfirst"; if ( !$this->mKeys ) { - $this->mKeys = array_map( 'ucfirst', array_keys( $wgAllMessagesEn ) ); + $this->mKeys = array_map( $ucfirst, array_keys( $wgAllMessagesEn ) ); } return $this->mKeys; } function isCacheable( $key ) { - global $wgAllMessagesEn; - return array_key_exists( lcfirst( $key ), $wgAllMessagesEn ) || + global $wgAllMessagesEn, $wgLang; + return array_key_exists( $wgLang->lcfirst( $key ), $wgAllMessagesEn ) || array_key_exists( $key, $wgAllMessagesEn ); } @@ -158,7 +159,7 @@ class MessageCache if ( $this->mDisable ) { return $wgLang->getMessage( $key ); } - $title = ucfirst( $key ); + $title = $wgLang->ucfirst( $key ); $message = false; @@ -197,8 +198,4 @@ class MessageCache return $message; } } - -function lcfirst( $s ) { - return strtolower( $s{0} ). substr( $s, 1 ); -} ?> diff --git a/languages/Language.php b/languages/Language.php index 85abdace7b..a86f065318 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1540,6 +1540,10 @@ class Language { return ucfirst( $string ); } + function lcfirst( $s ) { + return strtolower( $s{0} ). substr( $s, 1 ); + } + function checkTitleEncoding( $s ) { global $wgInputEncoding; diff --git a/languages/LanguageUtf8.php b/languages/LanguageUtf8.php index a0b622fb8a..2b9943b21c 100644 --- a/languages/LanguageUtf8.php +++ b/languages/LanguageUtf8.php @@ -25,6 +25,14 @@ class LanguageUtf8 extends Language { $string ); } + function lcfirst( $string ) { + global $wikiUpperChars, $wikiLowerChars; + return preg_replace ( + "/^([\\x00-\\x7f]|[\\xc0-\\xff][\\x80-\\xbf]*)/e", + "strtr ( \"\$1\" , \$wikiLowerChars )", + $string ); + } + function stripForSearch( $string ) { # MySQL fulltext index doesn't grok utf-8, so we # need to fold cases and convert to hex -- 2.20.1