/** @var Language */
protected $digitTransformLanguage;
- /** @var boolean */
+ /** @var bool */
private $useNumericCollation = false;
/** @var array */
foreach ( $letters as $letter ) {
$key = $this->getPrimarySortKey( $letter );
if ( isset( $letterMap[$key] ) ) {
- // Primary collision
- // Keep whichever one sorts first in the main collator
- if ( $this->mainCollator->compare( $letter, $letterMap[$key] ) < 0 ) {
+ // Primary collision (two characters with the same sort position).
+ // Keep whichever one sorts first in the main collator.
+ $comp = $this->mainCollator->compare( $letter, $letterMap[$key] );
+ wfDebug( "Primary collision '$letter' '{$letterMap[$key]}' (comparison: $comp)\n" );
+ // If that also has a collision, use codepoint as a tiebreaker.
+ if ( $comp === 0 ) {
+ // TODO Use <=> operator when PHP 7 is allowed.
+ $comp = UtfNormal\Utils::utf8ToCodepoint( $letter ) -
+ UtfNormal\Utils::utf8ToCodepoint( $letterMap[$key] );
+ }
+ if ( $comp < 0 ) {
$letterMap[$key] = $letter;
}
} else {
}
/**
+ * @param string $index
+ * @return string
* @since 1.16.3
*/
public function getLetterByIndex( $index ) {
}
/**
+ * @param string $index
+ * @return string
* @since 1.16.3
*/
public function getSortKeyByLetterIndex( $index ) {
}
/**
+ * @return string
* @since 1.16.3
*/
public function getFirstLetterCount() {
/**
* Test if a code point is a CJK (Chinese, Japanese, Korean) character
+ * @param int $codepoint
+ * @return bool
* @since 1.16.3
*/
public static function isCjk( $codepoint ) {
* @return string|bool
*/
static function getUnicodeVersionForICU() {
- $icuVersion = IcuCollation::getICUVersion();
+ $icuVersion = self::getICUVersion();
if ( !$icuVersion ) {
return false;
}
$versionPrefix = substr( $icuVersion, 0, 3 );
// Source: http://site.icu-project.org/download
$map = [
+ '59.' => '9.0',
+ '58.' => '9.0',
'57.' => '8.0',
'56.' => '8.0',
'55.' => '7.0',