function utf8_case_fold_nfkc($text, $option = 'full') { static $fc_nfkc_closure = array("ͺ" => " ι", "ϒ" => "υ", "ϓ" => "ύ", "ϔ" => "ϋ", "ϲ" => "σ", "Ϲ" => "σ", "ᴬ" => "a", "ᴭ" => "æ", "ᴮ" => "b", "ᴰ" => "d", "ᴱ" => "e", "ᴲ" => "ǝ", "ᴳ" => "g", "ᴴ" => "h", "ᴵ" => "i", "ᴶ" => "j", "ᴷ" => "k", "ᴸ" => "l", "ᴹ" => "m", "ᴺ" => "n", "ᴼ" => "o", "ᴽ" => "ȣ", "ᴾ" => "p", "ᴿ" => "r", "ᵀ" => "t", "ᵁ" => "u", "ᵂ" => "w", "₨" => "rs", "ℂ" => "c", "℃" => "°c", "ℇ" => "ɛ", "℉" => "°f", "ℋ" => "h", "ℌ" => "h", "ℍ" => "h", "ℐ" => "i", "ℑ" => "i", "ℒ" => "l", "ℕ" => "n", "№" => "no", "ℙ" => "p", "ℚ" => "q", "ℛ" => "r", "ℜ" => "r", "ℝ" => "r", "℠" => "sm", "℡" => "tel", "™" => "tm", "ℤ" => "z", "ℨ" => "z", "ℬ" => "b", "ℭ" => "c", "ℰ" => "e", "ℱ" => "f", "ℳ" => "m", "℻" => "fax", "ℾ" => "γ", "ℿ" => "π", "ⅅ" => "d", "㉐" => "pte", "㋌" => "hg", "㋎" => "ev", "㋏" => "ltd", "㍱" => "hpa", "㍳" => "au", "㍵" => "ov", "㍺" => "iu", "㎀" => "pa", "㎁" => "na", "㎂" => "μa", "㎃" => "ma", "㎄" => "ka", "㎅" => "kb", "㎆" => "mb", "㎇" => "gb", "㎊" => "pf", "㎋" => "nf", "㎌" => "μf", "㎐" => "hz", "㎑" => "khz", "㎒" => "mhz", "㎓" => "ghz", "㎔" => "thz", "㎩" => "pa", "㎪" => "kpa", "㎫" => "mpa", "㎬" => "gpa", "㎴" => "pv", "㎵" => "nv", "㎶" => "μv", "㎷" => "mv", "㎸" => "kv", "㎹" => "mv", "㎺" => "pw", "㎻" => "nw", "㎼" => "μw", "㎽" => "mw", "㎾" => "kw", "㎿" => "mw", "㏀" => "kω", "㏁" => "mω", "㏃" => "bq", "㏆" => "c∕kg", "㏇" => "co.", "㏈" => "db", "㏉" => "gy", "㏋" => "hp", "㏍" => "kk", "㏎" => "km", "㏗" => "ph", "㏙" => "ppm", "㏚" => "pr", "㏜" => "sv", "㏝" => "wb", "㏞" => "v∕m", "㏟" => "a∕m", "𝐀" => "a", "𝐁" => "b", "𝐂" => "c", "𝐃" => "d", "𝐄" => "e", "𝐅" => "f", "𝐆" => "g", "𝐇" => "h", "𝐈" => "i", "𝐉" => "j", "𝐊" => "k", "𝐋" => "l", "𝐌" => "m", "𝐍" => "n", "𝐎" => "o", "𝐏" => "p", "𝐐" => "q", "𝐑" => "r", "𝐒" => "s", "𝐓" => "t", "𝐔" => "u", "𝐕" => "v", "𝐖" => "w", "𝐗" => "x", "𝐘" => "y", "𝐙" => "z", "𝐴" => "a", "𝐵" => "b", "𝐶" => "c", "𝐷" => "d", "𝐸" => "e", "𝐹" => "f", "𝐺" => "g", "𝐻" => "h", "𝐼" => "i", "𝐽" => "j", "𝐾" => "k", "𝐿" => "l", "𝑀" => "m", "𝑁" => "n", "𝑂" => "o", "𝑃" => "p", "𝑄" => "q", "𝑅" => "r", "𝑆" => "s", "𝑇" => "t", "𝑈" => "u", "𝑉" => "v", "𝑊" => "w", "𝑋" => "x", "𝑌" => "y", "𝑍" => "z", "𝑨" => "a", "𝑩" => "b", "𝑪" => "c", "𝑫" => "d", "𝑬" => "e", "𝑭" => "f", "𝑮" => "g", "𝑯" => "h", "𝑰" => "i", "𝑱" => "j", "𝑲" => "k", "𝑳" => "l", "𝑴" => "m", "𝑵" => "n", "𝑶" => "o", "𝑷" => "p", "𝑸" => "q", "𝑹" => "r", "𝑺" => "s", "𝑻" => "t", "𝑼" => "u", "𝑽" => "v", "𝑾" => "w", "𝑿" => "x", "𝒀" => "y", "𝒁" => "z", "𝒜" => "a", "𝒞" => "c", "𝒟" => "d", "𝒢" => "g", "𝒥" => "j", "𝒦" => "k", "𝒩" => "n", "𝒪" => "o", "𝒫" => "p", "𝒬" => "q", "𝒮" => "s", "𝒯" => "t", "𝒰" => "u", "𝒱" => "v", "𝒲" => "w", "𝒳" => "x", "𝒴" => "y", "𝒵" => "z", "𝓐" => "a", "𝓑" => "b", "𝓒" => "c", "𝓓" => "d", "𝓔" => "e", "𝓕" => "f", "𝓖" => "g", "𝓗" => "h", "𝓘" => "i", "𝓙" => "j", "𝓚" => "k", "𝓛" => "l", "𝓜" => "m", "𝓝" => "n", "𝓞" => "o", "𝓟" => "p", "𝓠" => "q", "𝓡" => "r", "𝓢" => "s", "𝓣" => "t", "𝓤" => "u", "𝓥" => "v", "𝓦" => "w", "𝓧" => "x", "𝓨" => "y", "𝓩" => "z", "𝔄" => "a", "𝔅" => "b", "𝔇" => "d", "𝔈" => "e", "𝔉" => "f", "𝔊" => "g", "𝔍" => "j", "𝔎" => "k", "𝔏" => "l", "𝔐" => "m", "𝔑" => "n", "𝔒" => "o", "𝔓" => "p", "𝔔" => "q", "𝔖" => "s", "𝔗" => "t", "𝔘" => "u", "𝔙" => "v", "𝔚" => "w", "𝔛" => "x", "𝔜" => "y", "𝔸" => "a", "𝔹" => "b", "𝔻" => "d", "𝔼" => "e", "𝔽" => "f", "𝔾" => "g", "𝕀" => "i", "𝕁" => "j", "𝕂" => "k", "𝕃" => "l", "𝕄" => "m", "𝕆" => "o", "𝕊" => "s", "𝕋" => "t", "𝕌" => "u", "𝕍" => "v", "𝕎" => "w", "𝕏" => "x", "𝕐" => "y", "𝕬" => "a", "𝕭" => "b", "𝕮" => "c", "𝕯" => "d", "𝕰" => "e", "𝕱" => "f", "𝕲" => "g", "𝕳" => "h", "𝕴" => "i", "𝕵" => "j", "𝕶" => "k", "𝕷" => "l", "𝕸" => "m", "𝕹" => "n", "𝕺" => "o", "𝕻" => "p", "𝕼" => "q", "𝕽" => "r", "𝕾" => "s", "𝕿" => "t", "𝖀" => "u", "𝖁" => "v", "𝖂" => "w", "𝖃" => "x", "𝖄" => "y", "𝖅" => "z", "𝖠" => "a", "𝖡" => "b", "𝖢" => "c", "𝖣" => "d", "𝖤" => "e", "𝖥" => "f", "𝖦" => "g", "𝖧" => "h", "𝖨" => "i", "𝖩" => "j", "𝖪" => "k", "𝖫" => "l", "𝖬" => "m", "𝖭" => "n", "𝖮" => "o", "𝖯" => "p", "𝖰" => "q", "𝖱" => "r", "𝖲" => "s", "𝖳" => "t", "𝖴" => "u", "𝖵" => "v", "𝖶" => "w", "𝖷" => "x", "𝖸" => "y", "𝖹" => "z", "𝗔" => "a", "𝗕" => "b", "𝗖" => "c", "𝗗" => "d", "𝗘" => "e", "𝗙" => "f", "𝗚" => "g", "𝗛" => "h", "𝗜" => "i", "𝗝" => "j", "𝗞" => "k", "𝗟" => "l", "𝗠" => "m", "𝗡" => "n", "𝗢" => "o", "𝗣" => "p", "𝗤" => "q", "𝗥" => "r", "𝗦" => "s", "𝗧" => "t", "𝗨" => "u", "𝗩" => "v", "𝗪" => "w", "𝗫" => "x", "𝗬" => "y", "𝗭" => "z", "𝘈" => "a", "𝘉" => "b", "𝘊" => "c", "𝘋" => "d", "𝘌" => "e", "𝘍" => "f", "𝘎" => "g", "𝘏" => "h", "𝘐" => "i", "𝘑" => "j", "𝘒" => "k", "𝘓" => "l", "𝘔" => "m", "𝘕" => "n", "𝘖" => "o", "𝘗" => "p", "𝘘" => "q", "𝘙" => "r", "𝘚" => "s", "𝘛" => "t", "𝘜" => "u", "𝘝" => "v", "𝘞" => "w", "𝘟" => "x", "𝘠" => "y", "𝘡" => "z", "𝘼" => "a", "𝘽" => "b", "𝘾" => "c", "𝘿" => "d", "𝙀" => "e", "𝙁" => "f", "𝙂" => "g", "𝙃" => "h", "𝙄" => "i", "𝙅" => "j", "𝙆" => "k", "𝙇" => "l", "𝙈" => "m", "𝙉" => "n", "𝙊" => "o", "𝙋" => "p", "𝙌" => "q", "𝙍" => "r", "𝙎" => "s", "𝙏" => "t", "𝙐" => "u", "𝙑" => "v", "𝙒" => "w", "𝙓" => "x", "𝙔" => "y", "𝙕" => "z", "𝙰" => "a", "𝙱" => "b", "𝙲" => "c", "𝙳" => "d", "𝙴" => "e", "𝙵" => "f", "𝙶" => "g", "𝙷" => "h", "𝙸" => "i", "𝙹" => "j", "𝙺" => "k", "𝙻" => "l", "𝙼" => "m", "𝙽" => "n", "𝙾" => "o", "𝙿" => "p", "𝚀" => "q", "𝚁" => "r", "𝚂" => "s", "𝚃" => "t", "𝚄" => "u", "𝚅" => "v", "𝚆" => "w", "𝚇" => "x", "𝚈" => "y", "𝚉" => "z", "𝚨" => "α", "𝚩" => "β", "𝚪" => "γ", "𝚫" => "δ", "𝚬" => "ε", "𝚭" => "ζ", "𝚮" => "η", "𝚯" => "θ", "𝚰" => "ι", "𝚱" => "κ", "𝚲" => "λ", "𝚳" => "μ", "𝚴" => "ν", "𝚵" => "ξ", "𝚶" => "ο", "𝚷" => "π", "𝚸" => "ρ", "𝚹" => "θ", "𝚺" => "σ", "𝚻" => "τ", "𝚼" => "υ", "𝚽" => "φ", "𝚾" => "χ", "𝚿" => "ψ", "𝛀" => "ω", "𝛓" => "σ", "𝛢" => "α", "𝛣" => "β", "𝛤" => "γ", "𝛥" => "δ", "𝛦" => "ε", "𝛧" => "ζ", "𝛨" => "η", "𝛩" => "θ", "𝛪" => "ι", "𝛫" => "κ", "𝛬" => "λ", "𝛭" => "μ", "𝛮" => "ν", "𝛯" => "ξ", "𝛰" => "ο", "𝛱" => "π", "𝛲" => "ρ", "𝛳" => "θ", "𝛴" => "σ", "𝛵" => "τ", "𝛶" => "υ", "𝛷" => "φ", "𝛸" => "χ", "𝛹" => "ψ", "𝛺" => "ω", "𝜍" => "σ", "𝜜" => "α", "𝜝" => "β", "𝜞" => "γ", "𝜟" => "δ", "𝜠" => "ε", "𝜡" => "ζ", "𝜢" => "η", "𝜣" => "θ", "𝜤" => "ι", "𝜥" => "κ", "𝜦" => "λ", "𝜧" => "μ", "𝜨" => "ν", "𝜩" => "ξ", "𝜪" => "ο", "𝜫" => "π", "𝜬" => "ρ", "𝜭" => "θ", "𝜮" => "σ", "𝜯" => "τ", "𝜰" => "υ", "𝜱" => "φ", "𝜲" => "χ", "𝜳" => "ψ", "𝜴" => "ω", "𝝇" => "σ", "𝝖" => "α", "𝝗" => "β", "𝝘" => "γ", "𝝙" => "δ", "𝝚" => "ε", "𝝛" => "ζ", "𝝜" => "η", "𝝝" => "θ", "𝝞" => "ι", "𝝟" => "κ", "𝝠" => "λ", "𝝡" => "μ", "𝝢" => "ν", "𝝣" => "ξ", "𝝤" => "ο", "𝝥" => "π", "𝝦" => "ρ", "𝝧" => "θ", "𝝨" => "σ", "𝝩" => "τ", "𝝪" => "υ", "𝝫" => "φ", "𝝬" => "χ", "𝝭" => "ψ", "𝝮" => "ω", "𝞁" => "σ", "𝞐" => "α", "𝞑" => "β", "𝞒" => "γ", "𝞓" => "δ", "𝞔" => "ε", "𝞕" => "ζ", "𝞖" => "η", "𝞗" => "θ", "𝞘" => "ι", "𝞙" => "κ", "𝞚" => "λ", "𝞛" => "μ", "𝞜" => "ν", "𝞝" => "ξ", "𝞞" => "ο", "𝞟" => "π", "𝞠" => "ρ", "𝞡" => "θ", "𝞢" => "σ", "𝞣" => "τ", "𝞤" => "υ", "𝞥" => "φ", "𝞦" => "χ", "𝞧" => "ψ", "𝞨" => "ω", "𝞻" => "σ", "𝟊" => "ϝ"); global $phpbb_root_path, $phpEx; // do the case fold $text = utf8_case_fold($text, $option); if (!class_exists('utf_normalizer')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx; } // convert to NFKC utf_normalizer::nfkc($text); // FC_NFKC_Closure, http://www.unicode.org/Public/5.0.0/ucd/DerivedNormalizationProps.txt $text = strtr($text, $fc_nfkc_closure); return $text; }
/** * Assume the input is NFC: * Takes the input and does a "special" case fold. It does minor normalization as well. * * @param string $text text to be case folded * @param string $option determines how we will fold the cases * @return string case folded text */ function utf8_case_fold_nfc($text, $option = 'full') { static $uniarray = array(); static $ypogegrammeni = array( "\xCD\xBA" => "\x20\xCD\x85", "\xE1\xBE\x80" => "\xE1\xBC\x80\xCD\x85", "\xE1\xBE\x81" => "\xE1\xBC\x81\xCD\x85", "\xE1\xBE\x82" => "\xE1\xBC\x82\xCD\x85", "\xE1\xBE\x83" => "\xE1\xBC\x83\xCD\x85", "\xE1\xBE\x84" => "\xE1\xBC\x84\xCD\x85", "\xE1\xBE\x85" => "\xE1\xBC\x85\xCD\x85", "\xE1\xBE\x86" => "\xE1\xBC\x86\xCD\x85", "\xE1\xBE\x87" => "\xE1\xBC\x87\xCD\x85", "\xE1\xBE\x88" => "\xE1\xBC\x88\xCD\x85", "\xE1\xBE\x89" => "\xE1\xBC\x89\xCD\x85", "\xE1\xBE\x8A" => "\xE1\xBC\x8A\xCD\x85", "\xE1\xBE\x8B" => "\xE1\xBC\x8B\xCD\x85", "\xE1\xBE\x8C" => "\xE1\xBC\x8C\xCD\x85", "\xE1\xBE\x8D" => "\xE1\xBC\x8D\xCD\x85", "\xE1\xBE\x8E" => "\xE1\xBC\x8E\xCD\x85", "\xE1\xBE\x8F" => "\xE1\xBC\x8F\xCD\x85", "\xE1\xBE\x90" => "\xE1\xBC\xA0\xCD\x85", "\xE1\xBE\x91" => "\xE1\xBC\xA1\xCD\x85", "\xE1\xBE\x92" => "\xE1\xBC\xA2\xCD\x85", "\xE1\xBE\x93" => "\xE1\xBC\xA3\xCD\x85", "\xE1\xBE\x94" => "\xE1\xBC\xA4\xCD\x85", "\xE1\xBE\x95" => "\xE1\xBC\xA5\xCD\x85", "\xE1\xBE\x96" => "\xE1\xBC\xA6\xCD\x85", "\xE1\xBE\x97" => "\xE1\xBC\xA7\xCD\x85", "\xE1\xBE\x98" => "\xE1\xBC\xA8\xCD\x85", "\xE1\xBE\x99" => "\xE1\xBC\xA9\xCD\x85", "\xE1\xBE\x9A" => "\xE1\xBC\xAA\xCD\x85", "\xE1\xBE\x9B" => "\xE1\xBC\xAB\xCD\x85", "\xE1\xBE\x9C" => "\xE1\xBC\xAC\xCD\x85", "\xE1\xBE\x9D" => "\xE1\xBC\xAD\xCD\x85", "\xE1\xBE\x9E" => "\xE1\xBC\xAE\xCD\x85", "\xE1\xBE\x9F" => "\xE1\xBC\xAF\xCD\x85", "\xE1\xBE\xA0" => "\xE1\xBD\xA0\xCD\x85", "\xE1\xBE\xA1" => "\xE1\xBD\xA1\xCD\x85", "\xE1\xBE\xA2" => "\xE1\xBD\xA2\xCD\x85", "\xE1\xBE\xA3" => "\xE1\xBD\xA3\xCD\x85", "\xE1\xBE\xA4" => "\xE1\xBD\xA4\xCD\x85", "\xE1\xBE\xA5" => "\xE1\xBD\xA5\xCD\x85", "\xE1\xBE\xA6" => "\xE1\xBD\xA6\xCD\x85", "\xE1\xBE\xA7" => "\xE1\xBD\xA7\xCD\x85", "\xE1\xBE\xA8" => "\xE1\xBD\xA8\xCD\x85", "\xE1\xBE\xA9" => "\xE1\xBD\xA9\xCD\x85", "\xE1\xBE\xAA" => "\xE1\xBD\xAA\xCD\x85", "\xE1\xBE\xAB" => "\xE1\xBD\xAB\xCD\x85", "\xE1\xBE\xAC" => "\xE1\xBD\xAC\xCD\x85", "\xE1\xBE\xAD" => "\xE1\xBD\xAD\xCD\x85", "\xE1\xBE\xAE" => "\xE1\xBD\xAE\xCD\x85", "\xE1\xBE\xAF" => "\xE1\xBD\xAF\xCD\x85", "\xE1\xBE\xB2" => "\xE1\xBD\xB0\xCD\x85", "\xE1\xBE\xB3" => "\xCE\xB1\xCD\x85", "\xE1\xBE\xB4" => "\xCE\xAC\xCD\x85", "\xE1\xBE\xB7" => "\xE1\xBE\xB6\xCD\x85", "\xE1\xBE\xBC" => "\xCE\x91\xCD\x85", "\xE1\xBF\x82" => "\xE1\xBD\xB4\xCD\x85", "\xE1\xBF\x83" => "\xCE\xB7\xCD\x85", "\xE1\xBF\x84" => "\xCE\xAE\xCD\x85", "\xE1\xBF\x87" => "\xE1\xBF\x86\xCD\x85", "\xE1\xBF\x8C" => "\xCE\x97\xCD\x85", "\xE1\xBF\xB2" => "\xE1\xBD\xBC\xCD\x85", "\xE1\xBF\xB3" => "\xCF\x89\xCD\x85", "\xE1\xBF\xB4" => "\xCF\x8E\xCD\x85", "\xE1\xBF\xB7" => "\xE1\xBF\xB6\xCD\x85", "\xE1\xBF\xBC" => "\xCE\xA9\xCD\x85", ); // perform a small trick, avoid further normalization on composed points that contain U+0345 in their decomposition $text = strtr($text, $ypogegrammeni); // do the case fold $text = utf8_case_fold($text, $option); return $text; }
/** * Assume the input is NFC: * Takes the input and does a "special" case fold. It does minor normalization as well. * * @param string $text text to be case folded * @param string $option determines how we will fold the cases * @return string case folded text */ function utf8_case_fold_nfc($text, $option = 'full') { static $uniarray = array(); static $ypogegrammeni = array("ͺ" => " ͅ", "ᾀ" => "ᾀ", "ᾁ" => "ᾁ", "ᾂ" => "ᾂ", "ᾃ" => "ᾃ", "ᾄ" => "ᾄ", "ᾅ" => "ᾅ", "ᾆ" => "ᾆ", "ᾇ" => "ᾇ", "ᾈ" => "ᾈ", "ᾉ" => "ᾉ", "ᾊ" => "ᾊ", "ᾋ" => "ᾋ", "ᾌ" => "ᾌ", "ᾍ" => "ᾍ", "ᾎ" => "ᾎ", "ᾏ" => "ᾏ", "ᾐ" => "ᾐ", "ᾑ" => "ᾑ", "ᾒ" => "ᾒ", "ᾓ" => "ᾓ", "ᾔ" => "ᾔ", "ᾕ" => "ᾕ", "ᾖ" => "ᾖ", "ᾗ" => "ᾗ", "ᾘ" => "ᾘ", "ᾙ" => "ᾙ", "ᾚ" => "ᾚ", "ᾛ" => "ᾛ", "ᾜ" => "ᾜ", "ᾝ" => "ᾝ", "ᾞ" => "ᾞ", "ᾟ" => "ᾟ", "ᾠ" => "ᾠ", "ᾡ" => "ᾡ", "ᾢ" => "ᾢ", "ᾣ" => "ᾣ", "ᾤ" => "ᾤ", "ᾥ" => "ᾥ", "ᾦ" => "ᾦ", "ᾧ" => "ᾧ", "ᾨ" => "ᾨ", "ᾩ" => "ᾩ", "ᾪ" => "ᾪ", "ᾫ" => "ᾫ", "ᾬ" => "ᾬ", "ᾭ" => "ᾭ", "ᾮ" => "ᾮ", "ᾯ" => "ᾯ", "ᾲ" => "ᾲ", "ᾳ" => "ᾳ", "ᾴ" => "ᾴ", "ᾷ" => "ᾷ", "ᾼ" => "ᾼ", "ῂ" => "ῂ", "ῃ" => "ῃ", "ῄ" => "ῄ", "ῇ" => "ῇ", "ῌ" => "ῌ", "ῲ" => "ῲ", "ῳ" => "ῳ", "ῴ" => "ῴ", "ῷ" => "ῷ", "ῼ" => "ῼ"); global $src_root_path, $phpEx; // perform a small trick, avoid further normalization on composed points that contain U+0345 in their decomposition $text = strtr($text, $ypogegrammeni); // do the case fold $text = utf8_case_fold($text, $option); return $text; }