Home  >  Article  >  Backend Development  >  乱码问题,请教

乱码问题,请教

WBOY
WBOYOriginal
2016-06-23 13:43:11843browse



$city = $this->uri->segment(4);
//var_dump(json_decode($city,true)); 
//$city = iconv("utf-8","utf-8",$this->uri->segment(4));
$city = urldecode($this->uri->segment(4));
var_dump($city);
$city = iconv("ISO-8859-1","GBK",$city);
echo $city;
echo "
"."222";
print_r(iconv_get_encoding()); 


当前浏览器中页面的编码是gbk,用函数输出 是ISO-8859-1。  原始什么都不转换输出是%E5%8C%97%E4%BA%AC
浏览器换成unicode就显示正常了

搞一阵了,先谢谢了


回复讨论(解决方案)

用mb_convert_encoding??。

用mb_convert_encoding??。




不好使

搞定

header("content-Type: text/html; charset=utf-8"); 

还是这个好使

没有指定网页编码。

  $city = $this->uri->segment(4); 这种取值方法太笨,  再者这个城市的名称不可以用ID号来表示么

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn