乱码问题,请教
程序员文章站
2022-05-12 11:55:09
...
$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就显示正常了
搞一阵了,先谢谢了
不好使
//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号来表示么