手机交付搜索中文全部变成了“???????¤????”“???·?±??????”“?????????·??”

WBOY
Release: 2016-06-13 11:05:51
Original
899 people have browsed it

手机提交搜索中文全部变成了“???????¤????”“???·?±??????”“?????????·??”

本帖最后由 default7 于 2012-12-23 13:10:17 编辑 很奇怪的现象:
(1)使用手机进行关键词搜索,中文全部变成了“?????????·??”、拉丁字符的那种种。
(2)使用is_utf8检测$_GET[kw]返回的是utf-8的编码的。
(3)手机访问文件最开头直接 echo $_GET[kw]也是这个样子。。。电脑访问不是

相关配置:
(1)数据库类型MyISAM,表字符集utf8_general_ci,字段kw字符集 utf8_general_ci
(2)PHP版本:PHP Version 5.2.17,CGI/fast CGI
(3)System Linux sasin 2.6.32.36-hardened #9 SMP Tue Mar 29 09:29:20 PDT 2011 x86_64
(4)手机相关信息:
HTTP_ACCEPT_ENCODING = gzip
HTTP_ACCEPT_LANGUAGE = zh-CN
HTTP_USER_AGENT = Mozilla/5.0 (Linux; U; Android 2.3; zh-cn;HTC Build/GRJ90) UC AppleWebKit/534.31 (KHTML, like Gecko) Mobile Safari/534.31
HTTP_ACCEPT = application/xml,application/vnd.wap.xhtml+xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,text/vnd.wap.wml;q=0.6,*/*;q=0.5,UC/145,plugin/1
REMOTE_PORT = 49279
REQUEST_METHOD = GET
(5)手机浏览器 UC:8.7.2.214 Android

Copy after login


例子搜索的几个关键词:
引用
广州 -> ?????????·??
深圳 -> ???·?±??????
北京 -> ???????¤????



PHP函数 is_utf8(),来自PHP官网

function is_utf8($str) {
$c=0; $b=0;
$bits=0;
$len=strlen($str);
for($i=0; $i<$len; $i++){
$c=ord($str[$i]);
if($c > 128){
if(($c >= 254)) return false;
elseif($c >= 252) $bits=6;
elseif($c >= 248) $bits=5;
elseif($c >= 240) $bits=4;
elseif($c >= 224) $bits=3;
elseif($c >= 192) $bits=2;
else return false;
if(($i+$bits) > $len) return false;
while($bits > 1){
$i++;
$b=ord($str[$i]);
if($b < 128 || $b > 191) return false;
$bits--;
}
}
}
return true;
}
Copy after login






------解决方案--------------------
先发一个语言声明的头,看看
Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!