= 64 ) { throw new UnexpectedValueException( "Alphabet must be < 64 items" ); } $this->alphabet = $alphabet; $this->puaSubset = []; $len = count( $alphabet ); for ( $i = 0; $i < $len; $i++ ) { $this->puaSubset[] = "\xF3\xB3\x80" . chr( $i + 128 ); } parent::__construct( $lang ); } private function convertToPua( $string ) { return str_replace( $this->alphabet, $this->puaSubset, $string ); } public function getSortKey( $string ) { return $this->convertToPua( parent::getSortKey( $string ) ); } public function getFirstLetter( $string ) { // In case a title has a PUA code in it, make it sort // under the header for the character it would replace // to avoid inconsistent behaviour. This class mostly // assumes that people will not use PUA codes. return parent::getFirstLetter( str_replace( $this->puaSubset, $this->alphabet, $string ) ); } }