Using UTF-8 compatible ucfirst/lcfirst
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 25 Jan 2004 05:57:02 +0000 (05:57 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 25 Jan 2004 05:57:02 +0000 (05:57 +0000)
includes/MessageCache.php
languages/Language.php
languages/LanguageUtf8.php

index 8224840..5b95cef 100755 (executable)
@@ -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 );
-}
 ?>
index 85abdac..a86f065 100644 (file)
@@ -1540,6 +1540,10 @@ class Language {
                return ucfirst( $string );
        }
        
+       function lcfirst( $s ) {
+               return strtolower( $s{0}  ). substr( $s, 1 );
+       }
+
        function checkTitleEncoding( $s ) {
         global $wgInputEncoding;
                
index a0b622f..2b9943b 100644 (file)
@@ -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