本文整理汇总了PHP中utf8::utf8validator方法的典型用法代码示例。如果您正苦于以下问题:PHP utf8::utf8validator方法的具体用法?PHP utf8::utf8validator怎么用?PHP utf8::utf8validator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utf8
的用法示例。
在下文中一共展示了utf8::utf8validator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
self::$utf8validator = (bool) extension_loaded('utf8validator');
mb_internal_encoding('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
mb_detect_order(array('UTF-8', 'ISO-8859-1'));
mb_substitute_character(0xfffd);
MCached::connect();
$trans = MCached::get(self::TRANSKEY);
if ($trans === MCached::NO_RESULT) {
$win = "€" . implode('', range("‚", "Œ")) . "Ž" . implode('', range("‘", "œ")) . implode('', range("ž", "ÿ"));
$win_iso = "�����";
$iso = implode('', range("€", "ÿ"));
$winlen = strlen($win);
$winisolen = strlen($win_iso);
$isolen = strlen($iso);
$trans = array('iso_to_utf8' => array(), 'win_to_utf8' => array(), 'from_utf8' => array());
for ($i = 0; $i < $isolen; $i++) {
$utf8 = mb_convert_encoding($iso[$i], 'UTF-8', 'ISO-8859-1');
$trans['iso_to_utf8'][$iso[$i]] = $utf8;
$trans['from_utf8'][$utf8] = $iso[$i];
}
for ($i = 0; $i < $winlen; $i++) {
$utf8 = mb_convert_encoding($win[$i], 'UTF-8', 'Windows-1252');
$trans['win_to_utf8'][$win[$i]] = $utf8;
$trans['from_utf8'][$utf8] = $win[$i];
}
for ($i = 0; $i < $winisolen; $i++) {
$utf8 = mb_convert_encoding($win_iso[$i], 'UTF-8', 'ISO-8859-1');
$trans['win_to_utf8'][$win_iso[$i]] = $utf8;
}
MCached::add(self::TRANSKEY, $trans, 86400);
}
self::$trans_table = $trans;
}