编码转换不了,怪了
PHP code
var_dump($message);
$charset = mb_detect_encoding($message);
$message = iconv('UTF-8','GBK//IGNORE',$message);
//$message = mb_convert_encoding($message, 'GBK', 'UTF-8');
$charset2 = mb_detect_encoding($message);
var_dump($charset,$charset2,$message);
输出:
string '灏婃暚鐨刴ytest_0鎮ㄥソ锛佹偍鐨勮鍗?20120717-1504-6317宸叉敹鍒帮紝璇峰敖蹇€氳繃缃戜笂閾惰浠樻78.000鍏冿紝绁濇偍閲囪喘鎰夊揩锛佹湇鍔$儹绾匡細4001156677' (length=159)
string 'UTF-8' (length=5)
string 'UTF-8' (length=5)
string '灏婃暚鐨刴ytest_0鎮ㄥソ锛佹偍鐨勮鍗?20120717-1504-6317宸叉敹鍒帮紝璇峰敖蹇€氳繃缃戜笂閾惰浠樻78.000鍏冿紝绁濇偍閲囪喘鎰夊揩锛佹湇鍔$儹绾匡細4001156677' (length=159)
改变文件本身的编码也还是UTF-8
有人吗?在线等
------解决方案--------------------
试试加上
header("Content-Type:text/html;charset=utf-8");
------解决方案--------------------
error_reporting(E_ALL);
header("Content-Type:text/html;charset=utf-8");
是无BOM的UTF8吗?
有BOM可能是header失效