当我在浏览器中右键单击 xml 页面并保存 AS 并使用 Notepad++ 打开它时,非英文字符显示为 OK。但是,如果我编写一个脚本将页面保存到我的服务器,我会遇到字符编码问题。这真是令人头疼。有什么帮助吗?谢谢。
function download_page($path)
{
//$path = htmlentities($path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$path);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 280);
$retValue = curl_exec($ch);
if (!$retValue){ //echo "erro curl";
}
@curl_close($ch);
return $retValue;
}
$file= download_page($url);
$file = mb_convert_encoding($file, 'HTML-ENTITIES', "UTF-8");
$file = utf8_encode ($file);