public function uc( $str, $first = false ) {
if ( $first ) {
if ( $this->isMultibyte( $str ) ) {
- return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
+ return $this->mbUpperChar( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
} else {
return ucfirst( $str );
}
}
}
+ /**
+ * Convert character to uppercase, allowing overrides of the default mb_upper
+ * behaviour, which is buggy in many ways. Having a conversion table can be
+ * useful during transitions between PHP versions where unicode changes happen.
+ * This can make some resources unreachable on-wiki, see discussion at T219279.
+ * Providing such a conversion table can allow to manage the transition period.
+ *
+ * @since 1.34
+ *
+ * @param string $char
+ *
+ * @return string
+ */
+ protected function mbUpperChar( $char ) {
+ global $wgOverrideUcfirstCharacters;
+ if ( array_key_exists( $char, $wgOverrideUcfirstCharacters ) ) {
+ return $wgOverrideUcfirstCharacters[$char];
+ } else {
+ return mb_strtoupper( $char );
+ }
+ }
+
/**
* @param string $str
* @return mixed|string
}
/**
- * @return array
+ * @return string
*/
function fallback8bitEncoding() {
return self::$dataCache->getItem( $this->mCode, 'fallback8bitEncoding' );
}
} elseif ( $dispLen > $length && $dispLen > strlen( $ellipsis ) ) {
# String in fact does need truncation, the truncation point was OK.
+ // @phan-suppress-next-line PhanTypeInvalidExpressionArrayDestructuring
list( $ret, $openTags ) = $maybeState; // reload state
$ret = $this->removeBadCharLast( $ret ); // multi-byte char fix
$ret .= $ellipsis; // add ellipsis
return $this->mHtmlCode;
}
- /**
- * @param string $code
- * @deprecated since 1.32, use Language::factory to create a new object instead.
- */
- public function setCode( $code ) {
- wfDeprecated( __METHOD__, '1.32' );
- $this->mCode = $code;
- // Ensure we don't leave incorrect cached data lying around
- $this->mHtmlCode = null;
- $this->mParentLanguage = false;
- }
-
/**
* Get the language code from a file name. Inverse of getFileName()
* @param string $filename $prefix . $languageCode . $suffix