remove_accents() WP 1.2.1

Замінює всі нестандартні символи у тексті на єдиний стандарт ASCII.

Якщо символи, що підходять для конвертації, не будуть знайдені, то буде повернено переданий рядок.

Ця функція автоматично спрацьовує функції sanitize_title() .

Якщо вони не мають accent characters, то string given is just returned.

Accent characters converted:

Currency signs:

CodeGlyphReplacementDescription
U+00A3£(empty)British Pound sign
U+20ACEEuro sign

Decompositions for Latin-1 Supplement:

CodeGlyphReplacementDescription
U+00AAªaFeminine ordinal indicator
U+00BAºoMasculine ordinal indicator
U+00C0ÀALatin capital letter A with grave
U+00C1ÁALatin capital letter A with acute
U+00C2ÂALatin capital letter A with circumflex
U+00C3ÃALatin capital letter A with tilde
U+00C4ÄALatin capital letter A with diaeresis
U+00C5ÅALatin capital letter A with ring above
U+00C6ÆAELatin capital letter AE
U+00C7ÇCLatin capital letter C with cedilla
U+00C8ÈELatin capital letter E with grave
U+00C9ÉELatin capital letter E with acute
U+00CAÊELatin capital letter E with circumflex
U+00CBËELatin capital letter E with diaeresis
U+00CCÌILatin capital letter I with grave
U+00CDÍILatin capital letter I with acute
U+00CEÎILatin capital letter I with circumflex
U+00CFÏILatin capital letter I with diaeresis
U+00D0ÐDLatin capital letter Eth
U+00D1ÑNLatin capital letter N with tilde
U+00D2ÒOLatin capital letter O with grave
U+00D3ÓOLatin capital letter O with acute
U+00D4ÔOLatin capital letter O with circumflex
U+00D5ÕOLatin capital letter O with tilde
U+00D6ÖOLatin capital letter O with diaeresis
U+00D8ØOLatin capital letter O with stroke
U+00D9ÙULatin capital letter U with grave
U+00DAÚULatin capital letter U with acute
U+00DB¢ULatin capital letter U with circumflex
U+00DCÜULatin capital letter U with diaeresis
U+00DDÝYLatin capital letter Y with acute
U+00DEÞTHLatin capital letter Thorn
U+00DFßsLatin male letter sharp s
U+00E0àaLatin male letter a with grave
U+00E1áaLatin male letter a with acute
U+00E2âaLatin male letter a with circumflex
U+00E3ãaLatin male letter a with tilde
U+00E4äaLatin male letter a with diaeresis
U+00E5åaLatin male letter a with ring above
U+00E6æaeLatin male letter ae
U+00E7çcLatin male letter c with cedilla
U+00E8èeLatin male letter e with grave
U+00E9éeLatin small letter e with acute
U+00EAêeLatin male letter e with circumflex
U+00EBëeLatin small letter e with diaeresis
U+00ECìiLatin male letter i with grave
U+00EDíiLatin male letter i with acute
U+00EEîiLatin male letter i with circumflex
U+00EFïiLatin male letter i with diaeresis
U+00F0ðdLatin male letter Eth
U+00F1ñnLatin male letter n with tilde
U+00F2òoLatin male letter o with grave
U+00F3óoLatin male letter o with acute
U+00F4ôoLatin male letter o with circumflex
U+00F5õoLatin male letter o with tilde
U+00F6öoLatin male letter o with diaeresis
U+00F8øoLatin male letter o with stroke
U+00F9ùuLatin male letter u with grave
U+00FAúuLatin small letter u with acute
U+00FBûuLatin male letter u with circumflex
U+00FCüuLatin male letter u with diaeresis
U+00FDýyLatin male letter y with acute
U+00FEþthLatin male letter Thorn
U+00FFÿyLatin male letter y with diaeresis

Decompositions for Latin Extended-A:

CodeGlyphReplacementDescription
U+0100ĀALatin capital letter A with macron
U+0101āaLatin male letter a with macron
U+0102ĂALatin capital letter A with breve
U+0103ăaLatin male letter a with breve
U+0104ĄALatin capital letter A with ogonek
U+0105ąaLatin male letter a with ogonek
U+01006ĆCLatin capital letter C with acute
U+0107ćcLatin male letter c with acute
U+0108ĈCLatin capital letter C with circumflex
U+0109ĉcLatin male letter c with circumflex
U+010AĊCLatin capital letter C with dot above
U+010BċcLatin male letter c with dot above
U+010CČCLatin capital letter C with caron
U+010DčcLatin male letter c with caron
U+010EĎDLatin capital letter D with caron
U+010FдdLatin male letter d with caron
U+0110ĐDLatin capital letter D with stroke
U+0111đdLatin male letter d with stroke
U+0112ĒELatin capital letter E with macron
U+0113ēeLatin male letter e with macron
U+0114ĔELatin capital letter E with breve
U+0115ĕeLatin small letter e with breve
U+0116ĖELatin capital letter E with dot above
U+0117ėeLatin male letter e with dot above
U+0118ĘELatin capital letter E with ogonek
U+0119ęeLatin male letter e with ogonek
U+011AÈELatin capital letter E with caron
U+011BeeLatin small letter e with caron
U+011CrGLatin capital letter G with circumflex
U+011DĝgLatin male letter g with circumflex
U+011EĞGLatin capital letter G with breve
U+011FğgLatin male letter g with breve
U+0120ĠGLatin capital letter G with dot above
U+0121ġgLatin male letter g with dot above
U+0122¤GLatin capital letter G with cedilla
U+0123ЄgLatin male letter g with cedilla
U+0124ĤHLatin capital letter H with circumflex
U+0125ĥhLatin male letter h with circumflex
U+0126ĦHLatin capital letter H with stroke
U+0127ЄhLatin male letter h with stroke
U+0128ĨILatin capital letter I with tilde
U+0129ЕiLatin small letter i with tilde
U+012AĪILatin capital letter I with macron
U+012BīiLatin male letter i with macron
U+012CĬILatin capital letter I with breve
U+012DĭiLatin male letter i with breve
U+012EĮILatin capital letter I with ogonek
U+012FįiLatin male letter i with ogonek
U+0130İILatin capital letter I with dot above
U+0131ıiLatin male letter dotless i
U+0132IJIJLatin capital ligature IJ
U+0133ijijLatin невелика ligature ij
U+0134ĴJLatin capital letter J with circumflex
U+0135ĵjLatin male letter j with circumflex
U+0136ĶKLatin capital letter K with cedilla
U+0137ķkLatin male letter k with cedilla
U+0138ĸkLatin male letter Kra
U+0139ÅLLatin capital letter L with acute
U+013AĺlLatin male letter l with acute
U+013BØLLatin capital letter L with cedilla
U+013CļlLatin male letter l with cedilla
U+013DĽLLatin capital letter L with caron
U+013E¾lLatin male letter l with caron
U+013FĿLLatin capital letter L with middle dot
U+0140ŀlLatin male letter l with middle dot
U+0141ŁLLatin capital letter L with stroke
U+0142łlLatin male letter l with stroke
U+0143ŃNLatin capital letter N with acute
U+0144ńnLatin male letter N with acute
U+0145ŅNLatin capital letter N with cedilla
U+0146ņnLatin male letter n with cedilla
U+0147ŇNLatin capital letter N with caron
U+0148ňnLatin male letter n with caron
U+0149ʼnnLatin small letter n preceded by apostrophe
U+014AŊNLatin capital letter Eng
U+014BŋnLatin male letter Eng
U+014CŌOLatin capital letter O with macron
U+014DōoLatin male letter o with macron
U+014EŎOLatin capital letter O with breve
U+014FŏoLatin male letter o with breve
U+0150ŐOLatin capital letter O with double acute
U+0151őoLatin male letter o with double acute
U+0152ŒOELatin capital ligature OE
U+0153œoeLatin male ligature oe
U+0154ŔRLatin capital letter R with acute
U+0155ŕrLatin male letter r with acute
U+0156ŖRLatin capital letter R with cedilla
U+0157ŗrLatin male letter r with cedilla
U+0158РRLatin capital letter R with caron
U+0159rrLatin male letter r with caron
U+015AŚSLatin capital letter S with acute
U+015BśsLatin male letter s acute
U+015CŜSLatin capital letter S with circumflex
U+015DŝsLatin male letter s circumflex
U+015EŞSLatin capital letter S with cedilla
U+015FşsLatin male letter s with cedilla
U+0160ŠSLatin capital letter S with caron
U+0161šsLatin male letter s caron
U+0162ŢTLatin capital letter T with cedilla
U+0163ţtLatin male letter t with cedilla
U+0164ŤTLatin capital letter T with caron
U+0165тьtLatin male letter t with caron
U+0166ŦTLatin capital letter T with stroke
U+0167ŧtLatin male letter t with stroke
U+0168ŨULatin capital letter U with tilde
U+0169ũuLatin small letter u with tilde
U+016AŪULatin capital letter U з macron
U+016BūuLatin male letter u with macron
U+016CŬULatin capital letter U with breve
U+016DŭuLatin male letter u with breve
U+016EÔULatin capital letter U with ring above
U+016FůuLatin male letter u with ring above
U+0170ŰULatin capital letter U with double acute
U+0171űuLatin male letter u with double acute
U+0172ŲULatin capital letter U з огонеком
U+0173ųuLatin male letter u with ogonek
U+0174ŴWLatin capital letter W with circumflex
U+0175ŵwLatin male letter w with circumflex
U+0176ŶYLatin capital letter Y with circumflex
U+0177ŷyLatin male letter y with circumflex
U+0178ŸYLatin capital letter Y with diaeresis
U+0179ŹZLatin capital letter Z with acute
U+017AźzLatin male letter z with acute
U+017BŻZLatin capital letter Z with dot above
U+017CżzLatin male letter z with dot above
U+017DŽZLatin capital letter Z with caron
U+017EžzLatin male letter z with caron
U+017FſsLatin male letter long s
U+01A0ƠOLatin capital letter O with horn
U+01A1ơoLatin male letter o with horn
U+01AFƯULatin capital letter U with horn
U+01B0ưuLatin male letter u with horn
U+01CDǍALatin capital letter A with caron
U+01CEǎaLatin male letter a with caron
U+01CFǏILatin capital letter I with caron
U+01D0ǐiLatin male letter i with caron
U+01D1ǑOLatin capital letter O with caron
U+01D2ǒoLatin male letter o with caron
U+01D3ǓULatin capital letter U with caron
U+01D4ǔuLatin male letter u with caron
U+01D5ǕULatin capital letter U з діаресою і macron
U+01D6ǖuLatin male letter u with diaeresis and macron
U+01D7ǗULatin capital letter U with diaeresis and acute
U+01D8ǘuLatin male letter u with diaeresis and acute
U+01D9ǙULatin capital letter U with diaeresis and caron
U+01DAǚuLatin small letter u with diaeresis and caron
U+01DBǛULatin capital letter U з діаресою і grave
U+01DCǜuLatin male letter u with diaeresis and grave

Decompositions for Latin Extended-B:

CodeGlyphReplacementDescription
U+0218ȘSLatin capital letter S with comma below
U+0219șsLatin male letter s comma below
U+021AȚTLatin capital letter T with comma below
U+021BțtLatin male letter t with comma below

Vowels with diacritic (Chinese, Hanyu Pinyin):

CodeGlyphReplacementDescription
U+0251ɑaLatin male letter alpha
U+1EA0ALatin capital letter A with dot below
U+1EA1aLatin male letter a with dot below
U+1EA2ALatin capital letter A with hook above
U+1EA3aLatin male letter a with hook above
U+1EA4ALatin capital letter A with circumflex and acute
U+1EA5aLatin male letter a with circumflex and acute
U+1EA6ALatin capital letter A with circumflex and grave
U+1EA7aLatin male letter a with circumflex and grave
U+1EA8ALatin capital letter A with circumflex and hook above
U+1EA9aLatin male letter a with circumflex and hook above
U+1EAAALatin capital letter A with circumflex and tilde
U+1EABaLatin male letter a with circumflex and tilde
U+1EA6ALatin capital letter A with circumflex and dot below
U+1EADaLatin male letter a with circumflex and dot below
U+1EAEALatin capital letter A with breve and acute
U+1EAFaLatin male letter a with breve і acute
U+1EB0ALatin capital letter A with breve і grave
U+1EB1aLatin male letter a with breve і grave
U+1EB2ALatin capital letter A with breve and hook above
U+1EB3aLatin male letter a with breve і hook above
U+1EB4ALatin capital letter A with breve and tilde
U+1EB5aLatin male letter a with breve і tilde
U+1EB6ALatin capital letter A with breve and dot below
U+1EB7aLatin male letter a with breve і dot below
U+1EB8ELatin capital letter E with dot below
U+1EB9eLatin small letter e with dot below
U+1EBAELatin capital letter E with hook above
U+1EBBeLatin male letter e with hook above
U+1EBCELatin capital letter E with tilde
U+1EBDeLatin small letter e with tilde
U+1EBEELatin capital letter E with circumflex and acute
U+1EBFếeLatin male letter e with circumflex and acute
U+1EC0ELatin capital letter E with circumflex and grave
U+1EC1eLatin male letter e with circumflex and grave
U+1EC2ELatin capital letter E with circumflex and hook above
U+1EC3eLatin male letter e with circumflex and hook above
U+1EC4ELatin capital letter E with circumflex and tilde
U+1EC5eLatin male letter e with circumflex and tilde
U+1EC6ELatin capital letter E with circumflex and dot below
U+1EC7eLatin male letter e with circumflex and dot below
U+1EC8ILatin capital letter I with hook above
U+1EC9iLatin male letter i with hook above
U+1ECAILatin capital letter I with dot below
U+1ECBiLatin small letter i with dot below
U+1ECCOLatin capital letter O with dot below
U+1ECDoLatin male letter o with dot below
U+1ECEOLatin capital letter O with hook above
U+1ECFoLatin male letter o with hook above
U+1ED0OLatin capital letter O з circumflex and acute
U+1ED1oLatin male letter o with circumflex and acute
U+1ED2OLatin capital letter O з circumflex and grave
U+1ED3oLatin male letter o with circumflex and grave
U+1ED4OLatin capital letter O з circumflex and hook above
U+1ED5oLatin male letter o with circumflex and hook above
U+1ED6OLatin capital letter O with circumflex and tilde
U+1ED7oLatin male letter o with circumflex and tilde
U+1ED8OLatin capital letter O with circumflex and dot below
U+1ED9oLatin male letter o with circumflex and dot below
U+1EDAOLatin capital letter O with horn and acute
U+1EDBoLatin male letter o with horn and acute
U+1EDCOLatin capital letter O with horn and grave
U+1EDDoLatin male letter o with horn and grave
U+1EDEOLatin capital letter O with horn and hook above
U+1EDFoLatin male letter o with horn and hook above
U+1EE0OLatin capital letter O with horn and tilde
U+1EE1oLatin male letter o with horn and tilde
U+1EE2OLatin capital letter O with horn and dot below
U+1EE3oLatin small letter o with horn and dot below
U+1EE4ULatin capital letter U with dot below
U+1EE5uLatin small letter u with dot below
U+1EE6ULatin capital letter U with hook above
U+1EE7uLatin male letter u with hook above
U+1EE8ULatin capital letter U with horn and acute
U+1EE9uLatin small letter u with horn and acute
U+1EEAULatin capital letter U with horn and grave
U+1EEBuLatin male letter u with horn and grave
U+1EECULatin capital letter U with horn and hook above
U+1EEDuLatin male letter u with horn and hook above
U+1EEEULatin capital letter U with horn and tilde
U+1EEFuLatin small letter u with horn and tilde
U+1EF0ULatin capital letter U with horn and dot below
U+1EF1uLatin small letter u with horn and dot below
U+1EF2YLatin capital letter Y with grave
U+1EF3yLatin male letter y with grave
U+1EF4YLatin capital letter Y with dot below
U+1EF5yLatin male letter y with dot below
U+1EF6YLatin capital letter Y with hook above
U+1EF7yLatin male letter y with hook above
U+1EF8YLatin capital letter Y with tilde
U+1EF9yLatin male letter y with tilde

Німеччина ( de_DE ), Німеччина formal ( de_DE_formal ), Німеччина ( Switzerland ) formal ( de_CH ), Німеччина ( Switzerland ) інформаційна ( de_CH_informal ), і Німеччина ( Austria ) ( de_AT ) locals:

CodeGlyphReplacementDescription
U+00C4ÄAeLatin capital letter A with diaeresis
U+00E4äaeLatin male letter a with diaeresis
U+00D6ÖOeLatin capital letter O with diaeresis
U+00F6öoeLatin male letter o with diaeresis
U+00DCÜUeLatin capital letter U with diaeresis
U+00FCüueLatin male letter u with diaeresis
U+00DFßssLatin male letter sharp s

Danish ( da_DK ) locale:

CodeGlyphReplacementDescription
U+00C6ÆAeLatin capital letter AE
U+00E6æaeLatin male letter ae
U+00D8ØOeLatin capital letter O with stroke
U+00F8øoeLatin male letter o with stroke
U+00C5ÅAaLatin capital letter A with ring above
U+00E5åaaLatin male letter a with ring above

Catalan ( ca ) locale:

CodeGlyphReplacementDescription
U+00B7l·lllFlown dot (between two Ls)

Serbian ( sr_RS ) та Bosnian ( bs_BA ) locales:

CodeGlyphReplacementDescription
U+0110ĐDJLatin capital letter D with stroke
U+0111đdjLatin male letter d with stroke
1 раз – 0.000001 сек
(швидкість світла) | 50000 разів – 0.27 сек
(дуже швидко) |
PHP 7.2.5, WP 4.9.8

Хуків немає.

Повертає

Строку. Змінений текст.

Використання

remove_accents($string, $locale);
$string
(рядок) (обов’язковий)
Рядок в якому потрібно конвертувати символи ASCII.
$locale
(рядок) (WP 6.0)
Локаль (мова) сайту, деякі мови встановлюють інші правила обробки символів. За умовчанням локаль береться із функції
get_locale() .


За замовчуванням: ” – поточна локаль

Приклади

0

#1 Демонструючий заміну нестандартних символів приклад:

$text = "Hoy será un gran dia";
echo remove_accents ($text); //> Hoy sera un gran dia.

список змін

З версії 1.2.1Введено.
З версії 4.6.0Added locale support for de_CH , de_CH_informal , and ca.
З версії 4.7.0Added locale support for sr_RS .
З версії 4.8.0Added locale support for bs_BA .
З версії 5.7.0Added locale support for de_AT .
З версії 6.0.0Added the $locale parameter.

Код remove_accents() WP 6.0.2

function remove_accents( $string, $locale = '' ) {
	if ( ! preg_match( '/[x80-xff]/', $string ) ) {
		return $string;
	}

	if ( seems_utf8( $string ) ) {
		$chars = array(
			// Decompositions for Latin-1 Supplement.
			'ª' => 'a',
			'º' => 'o',
			'À' => 'A',
			'Á' => 'A',
			'Â' => 'A',
			'Ã' => 'A',
			'Ä' => 'A',
			'Å' => 'A',
			'Æ' => 'AE',
			'Ç' => 'C',
			'È' => 'E',
			'É' => 'E',
			'Ê' => 'E',
			'Ë' => 'E',
			'Ì' => 'I',
			'Í' => 'I',
			'Î' => 'I',
			'Ï' => 'I',
			'Ð' => 'D',
			'Ñ' => 'N',
			'Ò' => 'O',
			'Ó' => 'O',
			'Ô' => 'O',
			'Õ' => 'O',
			'Ö' => 'O',
			'Ù' => 'U',
			'Ú' => 'U',
			'U' => 'U',
			'Ü' => 'U',
			'Ý' => 'Y',
			'Þ' => 'TH',
			'ß' => 's',
			'à' => 'a',
			'á' => 'a',
			'â' => 'a',
			'ã' => 'a',
			'ä' => 'a',
			'å' => 'a',
			'æ' => 'ae',
			'ç' => 'c',
			'è' => 'e',
			'é' => 'e',
			'ê' => 'e',
			'ë' => 'e',
			'ì' => 'i',
			'í' => 'i',
			'î' => 'i',
			'ï' => 'i',
			'ð' => 'd',
			'ñ' => 'n',
			'ò' => 'o',
			'ó' => 'o',
			'ô' => 'o',
			'õ' => 'o',
			'ö' => 'o',
			'ø' => 'o',
			'ù' => 'u',
			'ú' => 'u',
			'û' => 'u',
			'ü' => 'u',
			'ý' => 'y',
			'þ' => 'th',
			'ÿ' => 'y',
			'Ø' => 'O',
			// Decompositions for Latin Extended-A.
			'Ā' => 'A',
			'ā' => 'a',
			'Ă' => 'A',
			'ă' => 'a',
			'Ą' => 'A',
			'ą' => 'a',
			'Ć' => 'C',
			'ć' => 'c',
			'Ĉ' => 'C',
			'ĉ' => 'c',
			'Ċ' => 'C',
			'ċ' => 'c',
			'Č' => 'C',
			'č' => 'c',
			'Д' => 'D',
			'ь' => 'd',
			'Đ' => 'D',
			'đ' => 'd',
			'Ē' => 'E',
			'ē' => 'e',
			'Ĕ' => 'E',
			'ĕ' => 'e',
			'Ė' => 'E',
			'ė' => 'e',
			'Ę' => 'E',
			'ę' => 'e',
			'Е' => 'E',
			'e' => 'e',
			'r' => 'G',
			'ĝ' => 'g',
			'Ğ' => 'G',
			'ğ' => 'g',
			'Ġ' => 'G',
			'ġ' => 'g',
			'T' => 'G',
			'ģ' => 'g',
			'Ĥ' => 'H',
			'ĥ' => 'h',
			'Ħ' => 'H',
			'ħ' => 'h',
			'Ĩ' => 'I',
			'ĩ' => 'i',
			'Ī' => 'I',
			'ī' => 'i',
			'Ĭ' => 'I',
			'ĭ' => 'i',
			'Į' => 'I',
			'į' => 'i',
			'İ' => 'I',
			'ı' => 'i',
			'IJ' => 'IJ',
			'ij' => 'ij',
			'Ĵ' => 'J',
			'ĵ' => 'j',
			'Ķ' => 'K',
			'ķ' => 'k',
			'ĸ' => 'k',
			'Å' => 'L',
			'ĺ' => 'l',
			'?' => 'L',
			'ļ' => 'l',
			'L' => 'L',
			'l' => 'l',
			'Ŀ' => 'L',
			'ŀ' => 'l',
			'Ł' => 'L',
			'ł' => 'l',
			'Ń' => 'N',
			'ń' => 'n',
			'Ņ' => 'N',
			'ņ' => 'n',
			'N' => 'N',
			'ň' => 'n',
			'ʼn' => 'n',
			'Ŋ' => 'N',
			'ŋ' => 'n',
			'Ō' => 'O',
			'ō' => 'o',
			'Ŏ' => 'O',
			'ŏ' => 'o',
			'Ő' => 'O',
			'ő' => 'o',
			'Œ' => 'OE',
			'œ' => 'oe',
			'Ŕ' => 'R',
			'ŕ' => 'r',
			'Ŗ' => 'R',
			'ŗ' => 'r',
			'R' => 'R',
			'r' => 'r',
			'Ś' => 'S',
			'ś' => 's',
			'Ŝ' => 'S',
			'ŝ' => 's',
			'Ş' => 'S',
			'ş' => 's',
			'Š' => 'S',
			'š' => 's',
			'Ţ' => 'T',
			'ţ' => 't',
			'Ť' => 'T',
			'ť' => 't',
			'Ŧ' => 'T',
			'ŧ' => 't',
			'Ũ' => 'U',
			'ũ' => 'u',
			'Ū' => 'U',
			'ū' => 'u',
			'Ŭ' => 'U',
			'ŭ' => 'u',
			'Ô' => 'U',
			'ů' => 'u',
			'Ű' => 'U',
			'ű' => 'u',
			'Ų' => 'U',
			'ų' => 'u',
			'Ŵ' => 'W',
			'ŵ' => 'w',
			'Ŷ' => 'Y',
			'ŷ' => 'y',
			'Ÿ' => 'Y',
			'Ź' => 'Z',
			'ź' => 'z',
			'Ż' => 'Z',
			'ż' => 'z',
			'Ž' => 'Z',
			'ž' => 'z',
			'ſ' => 's',
			// Decompositions for Latin Extended-B.
			'Ș' => 'S',
			'ș' => 's',
			'Ț' => 'T',
			'ț' => 't',
			// Euro Sign.
			'€' => 'E',
			// GBP (Pound) sign.
			'£' => '',
			// Vowels with diacritic (Vietnamese).
			// Unmarked.
			'Ơ' => 'O',
			'ơ' => 'o',
			'Ư' => 'U',
			'ư' => 'u',
			// Grave accent.
			'Ầ' => 'A',
			'ầ' => 'a',
			'Ằ' => 'A',
			'ằ' => 'a',
			'Ề' => 'E',
			'ề' => 'e',
			'Ồ' => 'O',
			'ồ' => 'o',
			'Ờ' => 'O',
			'ờ' => 'o',
			'Ừ' => 'U',
			'ừ' => 'u',
			'Ỳ' => 'Y',
			'ỳ' => 'y',
			// Hook.
			'Ả' => 'A',
			'ả' => 'a',
			'Ẩ' => 'A',
			'ẩ' => 'a',
			'Ẳ' => 'A',
			'ẳ' => 'a',
			'Ẻ' => 'E',
			'ẻ' => 'e',
			'Ể' => 'E',
			'ể' => 'e',
			'Ỉ' => 'I',
			'ỉ' => 'i',
			'Ỏ' => 'O',
			'ỏ' => 'o',
			'Ổ' => 'O',
			'ổ' => 'o',
			'Ở' => 'O',
			'ở' => 'o',
			'Ủ' => 'U',
			'ủ' => 'u',
			'Ử' => 'U',
			'ử' => 'u',
			'Ỷ' => 'Y',
			'ỷ' => 'y',
			// Tilde.
			'Ẫ' => 'A',
			'ẫ' => 'a',
			'Ẵ' => 'A',
			'ẵ' => 'a',
			'Ẽ' => 'E',
			'ẽ' => 'e',
			'Ễ' => 'E',
			'ễ' => 'e',
			'Ỗ' => 'O',
			'ỗ' => 'o',
			'Ỡ' => 'O',
			'ỡ' => 'o',
			'Ữ' => 'U',
			'ữ' => 'u',
			'Ỹ' => 'Y',
			'ỹ' => 'y',
			// Acute accent.
			'Ấ' => 'A',
			'ấ' => 'a',
			'Ắ' => 'A',
			'ắ' => 'a',
			'Ế' => 'E',
			'ế' => 'e',
			'Ố' => 'O',
			'ố' => 'o',
			'Ớ' => 'O',
			'ớ' => 'o',
			'Ứ' => 'U',
			'ứ' => 'u',
			// Dot below.
			'Ạ' => 'A',
			'ạ' => 'a',
			'Ậ' => 'A',
			'ậ' => 'a',
			'Ặ' => 'A',
			'ặ' => 'a',
			'Ẹ' => 'E',
			'ẹ' => 'e',
			'Ệ' => 'E',
			'ệ' => 'e',
			'Ị' => 'I',
			'ị' => 'i',
			'Ọ' => 'O',
			'ọ' => 'o',
			'Ộ' => 'O',
			'ộ' => 'o',
			'Ợ' => 'O',
			'ợ' => 'o',
			'Ụ' => 'U',
			'ụ' => 'u',
			'Ự' => 'U',
			'ự' => 'u',
			'Ỵ' => 'Y',
			'ỵ' => 'y',
			// Vowels with diacritic (Chinese, Hanyu Pinyin).
			'ɑ' => 'a',
			// Macron.
			'Ǖ' => 'U',
			'ǖ' => 'u',
			// Acute accent.
			'Ǘ' => 'U',
			'ǘ' => 'u',
			// Caron.
			'Ǎ' => 'A',
			'ǎ' => 'a',
			'Ǐ' => 'I',
			'ǐ' => 'i',
			'Ǒ' => 'O',
			'ǒ' => 'o',
			'Ǔ' => 'U',
			'ǔ' => ​​'u',
			'Ǚ' => 'U',
			'ǚ' => 'u',
			// Grave accent.
			'Ǜ' => 'U',
			'ǜ' => 'u',
		);

		// Used for locale-specific rules.
		if ( empty( $locale ) ) {
			$locale = get_locale();
		}

		/*
		 * Німеччина має різні місцеві організації (de_DE, de_CH, de_AT, ...) з formal and informal variants.
		 * Там не є 3-річним місцевим місцем, як 'def', тому що checking for 'de' instead of 'de_' is safe,
		 * since 'de' itself would be a valid locale too.
		 */
		if ( str_starts_with( $locale, 'de' ) ) {
			$chars['Ä'] = 'Ae';
			$chars['ä'] = 'ae';
			$chars['Ö'] = 'Oe';
			$chars['ö'] = 'oe';
			$chars['Ü'] = 'Ue';
			$chars['ü'] = 'ue';
			$chars['ß'] = 'ss';
		} elseif ( 'da_DK' === $locale ) {
			$chars['Æ'] = 'Ae';
			$chars['æ'] = 'ae';
			$chars['Ø'] = 'Oe';
			$chars['ø'] = 'oe';
			$chars['Å'] = 'Aa';
			$chars['å'] = 'aa';
		} elseif ( 'ca' === $locale ) {
			$chars['l·l'] = 'll';
		} elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) {
			$chars['Đ'] = 'DJ';
			$chars['đ'] = 'dj';
		}

		$ string = strtr ($ string, $ chars);
	} else {
		$chars = array();
		// Assume ISO-8859-1 if not UTF-8.
		$chars['in'] = "x80x83x8ax8ex9ax9e"
			. "x9fxa2xa5xb5xc0xc1xc2"
			. "xc3xc4xc5xc7xc8xc9xca"
			. "xcbxccxcdxcexcfxd1xd2"
			. "xd3xd4xd5xd6xd8xd9xda"
			. "xdbxdcxddxe0xe1xe2xe3"
			. "xe4xe5xe7xe8xe9xeaxeb"
			. "xecxedxeexefxf1xf2xf3"
			. "xf4xf5xf6xf8xf9xfaxfb"
			. "xfcxfdxff";

		$chars['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy';

		$string = strtr( $string, $chars['in'], $chars['out'] );
		$ double_chars = array ();
		$double_chars['in'] = array( "x8c", "x9c", "xc6", "xd0", "xde", "xdf", "xe6", "xx0", "xfe");
		$double_chars['out'] = array( 'OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
		$string = str_replace( $double_chars['in'], $double_chars['out'], $string );
	}

	return $string;
}

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *