带£的字符串;符号返回问题黑色菱形标记PHP


String with £ symbol returns question black diamond mark PHP

我从远程url中抓取元描述,当url包含"£"时,它在firefox中返回一个带有问号的黑钻石。当我在字符串上应用utf8_encode时,它应该返回"£",但是其他UTF字符将无法正确显示。我能做什么?

您是否在页面上设置了内容类型元标记?

http://www.w3schools.com/tags/att_meta_http_equiv.asp

编辑:

为了解决你在评论中写的问题,我可能会这样做(超级快速和肮脏):

<?php
$ch = curl_init('http://www.dailymail.co.uk/health/article-1374575/Under-18s-sunbed-ban-cut-skin-cancer-toll.html');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
preg_match('/(<meta[^'n]+)(name='"description'"[^'n])(content='")([^'n]+)('")/', $data, $m);
echo urlencode($m[4]);
?>

话虽如此,正确的方法是解析由curl_exec返回的HTML,找到适当的节点(与name="description")并返回content属性的urlencode d值