http://bbs.csdn.net/topics/390955789?page=1#post-398687303
header("content-Type: text/html; charset=utf-8"); 当页面浏览器换一个编码就可正常显示中文时,可用 这个方法设置页面默认查看编码。
$degreename =urldecode($this->uri->segment(3));
------------------------------------------------------------------------------------------------------------------------
另外,其它乱码可以
$city = iconv("ISO-8859-1","GBK",$city);
$city = mb_convert_encoding($city,"utf-8");
var_dump(json_decode($city,true));
$city = urldecode(“string”);
实例2
CI下载文件功能
<span style="font-size:18px;">function project_statistics(){ $this->load->helper('download'); $this->load->helper('string'); $imgname = "1寸蓝底.jpg"; $imgname = mb_convert_encoding($imgname,"gbk"); $path = "../upload/image/$imgname"; //echo $path; //die(); $data = file_get_contents($path); // 读文件内容 $name = "$imgname"; force_download($name, $data); die();</span>
你是 windows 系统
如果程序是 utf-8 的话,那就要将文件名转成 gbk 编码的
实例3
如果是js弹出alert字符为乱码 可以在输出前加一句标头utf-8
echo '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>';
echo '<script>alert("您输入的密码存在错误,请核实再进行更改!");history.go(-1);</script>';
echo '<script>alert("该手机号码未注册过,请检查是否正确!");location.href="'.base_url().'member/forget_passwd";</script>';