PhpTransliteration
class PhpTransliteration extends PhpTransliteration (View source)
Enhances PhpTransliteration with an alter hook.
Properties
| protected string | $dataDirectory | Directory where data for transliteration resides. |
from PhpTransliteration |
| protected array | $languageOverrides | Associative array of language-specific character transliteration tables. |
from PhpTransliteration |
| protected array | $genericMap | Non-language-specific transliteration tables. |
from PhpTransliteration |
| protected | $fixTransliterateForRemoveDiacritics | Special characters for ::removeDiacritics(). |
from PhpTransliteration |
| protected ModuleHandlerInterface | $moduleHandler | The module handler to execute the transliteration_overrides alter hook. |
Methods
Constructs a PhpTransliteration object.
Removes diacritics (accents) from certain letters.
Transliterates text from Unicode to US-ASCII.
Finds the character code for a UTF-8 character: like ord() but for UTF-8.
Replaces a single Unicode character using the transliteration database.
Look up the generic replacement for a UTF-8 character code.
Overrides \Drupal\Component\Transliteration\PhpTransliteration::readLanguageOverrides().
Reads in generic transliteration data for a bank of characters.
Details
__construct(string $data_directory, ModuleHandlerInterface $module_handler)
Constructs a PhpTransliteration object.
string
removeDiacritics(string $string)
Removes diacritics (accents) from certain letters.
This only applies to certain letters: Accented Latin characters like a-with-acute-accent, in the UTF-8 character range of 0xE0 to 0xE6 and 01CD to 024F. Replacements that would result in the string changing length are excluded, as well as characters that are not accented US-ASCII letters.
string
transliterate(string $string, string $langcode = 'en', string $unknown_character = '?', int $max_length = NULL)
Transliterates text from Unicode to US-ASCII.
static protected int
ordUTF8(string $character)
Finds the character code for a UTF-8 character: like ord() but for UTF-8.
protected string
replace(int $code, string $langcode, string $unknown_character)
Replaces a single Unicode character using the transliteration database.
protected string
lookupReplacement($code, string $unknown_character = '?')
Look up the generic replacement for a UTF-8 character code.
protected
readLanguageOverrides($langcode)
Overrides \Drupal\Component\Transliteration\PhpTransliteration::readLanguageOverrides().
Allows modules to alter the language-specific $overrides array by invoking hook_transliteration_overrides_alter().
protected
readGenericData($bank)
Reads in generic transliteration data for a bank of characters.
The data is read in from a file named "x$bank.php" (with $bank in hexadecimal notation) in PhpTransliteration::$dataDirectory. These files should set up a variable $bank containing an array whose numerical indices are the remaining two bytes of the character code, and whose values are the transliterations of these characters into US-ASCII. Note that the maximum Unicode character that can be encoded in this way is 4 bytes.