'ک', 'ي' => 'ی', 'ى' => 'ی', 'ة' => 'ه', 'ﻻ' => 'لا', // Invisible characters that survive copy-paste. "\u{200C}" => ' ', // zero-width non-joiner. "\u{200D}" => '', // zero-width joiner. "\u{200E}" => '', // left-to-right mark. "\u{200F}" => '', // right-to-left mark. "\u{FEFF}" => '', // byte-order mark. "\u{00A0}" => ' ', // non-breaking space. // Diacritics, which are decorative in place names. "\u{064B}" => '', "\u{064C}" => '', "\u{064D}" => '', "\u{064E}" => '', "\u{064F}" => '', "\u{0650}" => '', "\u{0651}" => '', "\u{0652}" => '', ]; /** * Arabic-Indic and Persian digits mapped to ASCII. */ private const DIGITS = [ // Arabic-Indic. '٠' => '0', '١' => '1', '٢' => '2', '٣' => '3', '٤' => '4', '٥' => '5', '٦' => '6', '٧' => '7', '٨' => '8', '٩' => '9', // Persian. '۰' => '0', '۱' => '1', '۲' => '2', '۳' => '3', '۴' => '4', '۵' => '5', '۶' => '6', '۷' => '7', '۸' => '8', '۹' => '9', ]; /** * Normalise a province or city name for storage and comparison. * * @param string $value Raw name. */ public static function place( string $value ): string { $value = strtr( $value, self::FOLD ); $value = (string) preg_replace( '/\s+/u', ' ', $value ); return trim( $value ); } /** * Normalise digits to ASCII, leaving everything else alone. * * @param string $value Raw text. */ public static function digits( string $value ): string { return strtr( $value, self::DIGITS ); } }