var $minSearchLength;
var $mExtendedSpecialPageAliases;
+ /**
+ * ReplacementArray object caches
+ */
+ var $transformData = array();
+
static public $dataCache;
static public $mLangObjCache = array();
}
function ucfirst( $str ) {
- if ( empty($str) ) return $str;
- if ( ord($str[0]) < 128 ) return ucfirst($str);
- else return self::uc($str,true); // fall back to more complex logic in case of multibyte strings
+ $o = ord( $str );
+ if ( $o < 96 ) {
+ return $str;
+ } elseif ( $o < 128 ) {
+ return ucfirst($str);
+ } else {
+ // fall back to more complex logic in case of multibyte strings
+ return self::uc($str,true);
+ }
}
function uc( $str, $first = false ) {
}
function lcfirst( $str ) {
- if ( empty($str) ) return $str;
- if ( is_string( $str ) && ord($str[0]) < 128 ) {
- // editing string in place = cool
- $str[0]=strtolower($str[0]);
+ $o = ord( $str );
+ if ( !$o ) {
+ return strval( $str );
+ } elseif ( $o >= 128 ) {
+ return self::lc( $str, true );
+ } elseif ( $o > 96 ) {
+ return $str;
+ } else {
+ $str[0] = strtolower( $str[0] );
return $str;
}
- else return self::lc( $str, true );
}
function lc( $str, $first = false ) {
}
}
+ /**
+ * Convert a UTF-8 string to normal form C. In Malayalam and Arabic, this
+ * also cleans up certain backwards-compatible sequences, converting them
+ * to the modern Unicode equivalent.
+ *
+ * This is language-specific for performance reasons only.
+ */
+ function normalize( $s ) {
+ return UtfNormal::cleanUp( $s );
+ }
+
+ /**
+ * Transform a string using serialized data stored in the given file (which
+ * must be in the serialized subdirectory of $IP). The file contains pairs
+ * mapping source characters to destination characters.
+ *
+ * The data is cached in process memory. This will go faster if you have the
+ * FastStringSearch extension.
+ */
+ function transformUsingPairFile( $file, $string ) {
+ if ( !isset( $this->transformData[$file] ) ) {
+ $data = wfGetPrecompiledData( $file );
+ if ( $data === false ) {
+ throw new MWException( __METHOD__.": The transformation file $file is missing" );
+ }
+ $this->transformData[$file] = new ReplacementArray( $data );
+ }
+ return $this->transformData[$file]->replace( $string );
+ }
+
/**
* For right-to-left language support
*
function getMagic( $mw ) {
if ( !$this->mMagicHookDone ) {
$this->mMagicHookDone = true;
+ wfProfileIn( 'LanguageGetMagic' );
wfRunHooks( 'LanguageGetMagic', array( &$this->mMagicExtensions, $this->getCode() ) );
+ wfProfileOut( 'LanguageGetMagic' );
}
if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
$rawEntry = $this->mMagicExtensions[$mw->mId];
}
- function getPreferredVariant( $fromUser = true ) {
- return $this->mConverter->getPreferredVariant( $fromUser );
+ function getPreferredVariant( $fromUser = true, $fromHeader = false ) {
+ return $this->mConverter->getPreferredVariant( $fromUser, $fromHeader );
}
/**