TransliterationInterface.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Drupal\Component\Transliteration;
  3. /**
  4. * Defines an interface for classes providing transliteration.
  5. *
  6. * @ingroup transliteration
  7. */
  8. interface TransliterationInterface {
  9. /**
  10. * Removes diacritics (accents) from certain letters.
  11. *
  12. * This only applies to certain letters: Accented Latin characters like
  13. * a-with-acute-accent, in the UTF-8 character range of 0xE0 to 0xE6 and
  14. * 01CD to 024F. Replacements that would result in the string changing length
  15. * are excluded, as well as characters that are not accented US-ASCII letters.
  16. *
  17. * @param string $string
  18. * The string holding diacritics.
  19. *
  20. * @return string
  21. * $string with accented letters replaced by their unaccented equivalents.
  22. */
  23. public function removeDiacritics($string);
  24. /**
  25. * Transliterates text from Unicode to US-ASCII.
  26. *
  27. * @param string $string
  28. * The string to transliterate.
  29. * @param string $langcode
  30. * (optional) The language code of the language the string is in. Defaults
  31. * to 'en' if not provided. Warning: this can be unfiltered user input.
  32. * @param string $unknown_character
  33. * (optional) The character to substitute for characters in $string without
  34. * transliterated equivalents. Defaults to '?'.
  35. * @param int $max_length
  36. * (optional) If provided, return at most this many characters, ensuring
  37. * that the transliteration does not split in the middle of an input
  38. * character's transliteration.
  39. *
  40. * @return string
  41. * $string with non-US-ASCII characters transliterated to US-ASCII
  42. * characters, and unknown characters replaced with $unknown_character.
  43. */
  44. public function transliterate($string, $langcode = 'en', $unknown_character = '?', $max_length = NULL);
  45. }