66 throw new UnexpectedValueException(
"Alphabet must be < 4096 items" );
75 $this->puaSubset = [];
77 for ( $i = 0; $i < $len; $i++ ) {
78 $this->puaSubset[] =
"\xF3\xB3" . chr( floor( $i / 64 ) + 128 ) . chr( ( $i % 64 ) + 128 );
83 $lengths = array_map(
'mb_strlen', $this->alphabet );
84 array_multisort( $lengths, SORT_DESC, $this->firstLetters, $this->alphabet, $this->puaSubset );
90 return str_replace( $this->alphabet, $this->puaSubset, $string );
94 return $this->
convertToPua( parent::getSortKey( $string ) );
103 $index = array_search( substr( $sortkey, 0, 4 ), $this->puaSubset );
104 if ( $index !==
false ) {
105 return $this->firstLetters[ $index ];
109 return parent::getFirstLetter( $string );
Resort normal UTF-8 order by putting a bunch of stuff in PUA.
getSortKey( $string)
Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.
array $puaSubset
List of private use area codes.
getFirstLetter( $string)
Given a string, return the logical "first letter" to be used for grouping on category pages and so on...
__construct(LanguageFactory $languageFactory, array $alphabet, $digitTransformLang)
array $alphabet
Sorted array of letters.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Collation that orders text with numbers "naturally", so that 'Foo 1' < 'Foo 2' < 'Foo 12'.
Language $digitTransformLang
How to convert digits (usually the content language)