Replaces a single Unicode character using the transliteration database.
int $code: The character code of a Unicode character.
string $langcode: The language code of the language the character is in.
string $unknown_character: The character to substitute for characters without transliterated equivalents.
string US-ASCII replacement character. If it has a mapping, it is returned; otherwise, $unknown_character is returned.
protected function replace($code, $langcode, $unknown_character) {
if ($code < 0x80) {
// Already lower ASCII.
return chr($code);
}
// See if there is a language-specific override for this character.
if (!isset($this->languageOverrides[$langcode])) {
$this
->readLanguageOverrides($langcode);
}
if (isset($this->languageOverrides[$langcode][$code])) {
return $this->languageOverrides[$langcode][$code];
}
// See if there is a generic mapping for this character.
$bank = $code >> 8;
if (!isset($this->genericMap[$bank])) {
$this
->readGenericData($bank);
}
$code = $code & 0xff;
return isset($this->genericMap[$bank][$code]) ? $this->genericMap[$bank][$code] : $unknown_character;
}