function PhpTransliteration::lookupReplacement

Same name in other branches
  1. 8.9.x core/lib/Drupal/Component/Transliteration/PhpTransliteration.php \Drupal\Component\Transliteration\PhpTransliteration::lookupReplacement()
  2. 10 core/lib/Drupal/Component/Transliteration/PhpTransliteration.php \Drupal\Component\Transliteration\PhpTransliteration::lookupReplacement()
  3. 11.x core/lib/Drupal/Component/Transliteration/PhpTransliteration.php \Drupal\Component\Transliteration\PhpTransliteration::lookupReplacement()

Look up the generic replacement for a UTF-8 character code.

Parameters

$code: The UTF-8 character code.

string $unknown_character: (optional) The character to substitute for characters without entries in the replacement tables.

Return value

string US-ASCII replacement characters. If it has a mapping, it is returned; otherwise, $unknown_character is returned. The replacement can contain multiple characters.

2 calls to PhpTransliteration::lookupReplacement()
PhpTransliteration::removeDiacritics in core/lib/Drupal/Component/Transliteration/PhpTransliteration.php
Removes diacritics (accents) from certain letters.
PhpTransliteration::replace in core/lib/Drupal/Component/Transliteration/PhpTransliteration.php
Replaces a single Unicode character using the transliteration database.

File

core/lib/Drupal/Component/Transliteration/PhpTransliteration.php, line 258

Class

PhpTransliteration
Implements transliteration without using the PECL extensions.

Namespace

Drupal\Component\Transliteration

Code

protected function lookupReplacement($code, $unknown_character = '?') {
    // 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 $this->genericMap[$bank][$code] ?? $unknown_character;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.