59 throw new UnexpectedValueException(
"Alphabet must be < 4096 items" );
65 $this->puaSubset = [];
67 for ( $i = 0; $i < $len; $i++ ) {
68 $this->puaSubset[] =
"\xF3\xB3" . chr( floor( $i / 64 ) + 128 ) . chr( ( $i % 64 ) + 128 );
73 $lengths = array_map(
'mb_strlen', $this->alphabet );
74 array_multisort( $lengths, SORT_DESC, $this->firstLetters, $this->alphabet, $this->puaSubset );
76 parent::__construct(
$lang );
80 return str_replace( $this->alphabet, $this->puaSubset, $string );
84 return $this->
convertToPua( parent::getSortKey( $string ) );
93 $index = array_search( substr( $sortkey, 0, 4 ), $this->puaSubset );
94 if ( $index !==
false ) {
95 return $this->firstLetters[ $index ];
99 return parent::getFirstLetter( $string );