public static function TwigTweakExtension::transliterateFilter in Twig Tweak 3.x
Same name and namespace in other branches
- 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::transliterateFilter()
Transliterates text from Unicode to US-ASCII.
Parameters
string $text: The $text to transliterate.
string $langcode: (optional) The language code of the language the string is in. Defaults to 'en' if not provided. Warning: this can be unfiltered user input.
string $unknown_character: (optional) The character to substitute for characters in $string without transliterated equivalents. Defaults to '?'.
int $max_length: (optional) If provided, return at most this many characters, ensuring that the transliteration does not split in the middle of an input character's transliteration.
Return value
string $string with non-US-ASCII characters transliterated to US-ASCII characters, and unknown characters replaced with $unknown_character.
File
- src/
TwigTweakExtension.php, line 523
Class
- TwigTweakExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public static function transliterateFilter(string $text, string $langcode = 'en', string $unknown_character = '?', int $max_length = NULL) {
return \Drupal::transliteration()
->transliterate($text, $langcode, $unknown_character, $max_length);
}