<?php
function utf82gb($text, &$charset) {
$p = "/[xf0-xf7][x80-xbf]{3}|[xe0-xef][x80-xbf]{2}|[xc2-xdf][x80-xbf]|[x01-x7f]+/";
preg_match_all($p,$text,$r);
$utf8 = array_flip($charset);
foreach($r[0] as $k=>$v)
if(isset($utf8[$v]))
$r[0][$k] = $utf8[$v];
return join('',$r[0]);
}$s = gb2utf8('这是对照表的测试');
echo utf82gb($s,$charset);
?>
唠叨在喜悦村的,link:http://php.phpx.com/happy/thread-90509-3-1.html
function utf82gb($text, &$charset) {
$p = "/[xf0-xf7][x80-xbf]{3}|[xe0-xef][x80-xbf]{2}|[xc2-xdf][x80-xbf]|[x01-x7f]+/";
preg_match_all($p,$text,$r);
$utf8 = array_flip($charset);
foreach($r[0] as $k=>$v)
if(isset($utf8[$v]))
$r[0][$k] = $utf8[$v];
return join('',$r[0]);
}$s = gb2utf8('这是对照表的测试');
echo utf82gb($s,$charset);
?>
唠叨在喜悦村的,link:http://php.phpx.com/happy/thread-90509-3-1.html
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货