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