windows 操作系统
$encodename = "windows 操作系统";
echo urldecode($encodename);
$encodename = "windows 操作系统";
echo urldecode($encodename);
解决方案 »
- 使用"@"与"在php.ini里配置屏蔽notice信息"哪个性能好,效率高?
- 求助:PHP调试
- 问一个技术问题,关于substr 和mb_substr
- 急!!pdo_odbc连接db2报invalid data source name错误
- Delphi多用户查询问题!
- 到底是新网的错,不是firefox的错,还是ie的错?
- 请问Php如何将一些特殊字符保存到数据库,数据库是Mysql,数据由页面提交页面
- smarty的问题???
- function SE_accept($url,$mid,$name="确认") 为何意?
- 请问大侠:为什么程序中相应模块在php4.0可以执行而在php4.3中却无法执行(运行环境:win98+apache1.3.12)?
- 想问下有没有免费的类似猪八戒网这样的程序?
- 高分求助,在线等,急。问题不难
echo unicode2utf8($sheet[0]); function u2utf82gb($c){
$str="";
if ($c < 0x80) {
$str.=$c;
} else if ($c < 0x800) {
$str.=chr(0xC0 | $c>>6);
$str.=chr(0x80 | $c & 0x3F);
} else if ($c < 0x10000) {
$str.=chr(0xE0 | $c>>12);
$str.=chr(0x80 | $c>>6 & 0x3F);
$str.=chr(0x80 | $c & 0x3F);
} else if ($c < 0x200000) {
$str.=chr(0xF0 | $c>>18);
$str.=chr(0x80 | $c>>12 & 0x3F);
$str.=chr(0x80 | $c>>6 & 0x3F);
$str.=chr(0x80 | $c & 0x3F);
}
return iconv('utf-8', 'gb2312', $str);
}
function unicode2utf8($str){
$str = preg_replace("|&#([0-9]{1,5});|", "\".u2utf82gb(\\1).\"", $str);
$str = "\$str=\"$str\";";
return eval($str);
}
自动转换
问题已经解决谢谢各位
/*######################################################################################################
示例 unicode2gbk($str);
$strs="product intr…";
echo unescape($strs); //输出 windows 操作系统
作用编码转换 将 unicode -> GB2312[支持中英文]
*******************************************************************************************************/
function unescape($strs) {
if(empty($strs)):
return;
endif;
$arr=split("&#",$strs);
$strs=implode(";&#",$arr).';';//在每段中加上分号
//$string=substr($strs, 1);
$str = rawurldecode($strs);
preg_match_all("/(?:%u.{4})|&#x.{4};|&#\d+;|.+/U",$str,$r);
$ar = $r[0];
//print_r($ar);
foreach($ar as $k=>$v) {
if(substr($v,0,2) == "%u")
$ar[$k] = iconv("UCS-2","GB2312",pack("H4",substr($v,-4)));
elseif(substr($v,0,3) == "&#x")
$ar[$k] = iconv("UCS-2","GB2312",pack("H4",substr($v,3,-1)));
elseif(substr($v,0,2) == "&#") {
//echo substr($v,2,-1)."<br>";
$ar[$k] = iconv("UCS-2","GB2312",pack("n",substr($v,2,-1)));
}
}
$string=join("",$ar);
$patterns=array("|^;(.+?)|","|(.+?);$|");
$replacements=array("\\1","\\1");
//去除最前后面的分号
$strs = preg_replace($patterns, $replacements, $string);
return $strs;
}