Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带£的字符串;符号返回问号黑色菱形标记PHP_Php_Encoding_Utf_Html Entities - Fatal编程技术网

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

带£的字符串;符号返回问号黑色菱形标记PHP,php,encoding,utf,html-entities,Php,Encoding,Utf,Html Entities,我从远程url获取元描述,当url包含“£”时,它会在firefox中返回一个带问号的黑钻石。当我在字符串上应用utf8_编码时,它会返回它应该返回的“£”,但是其他UTF字符将无法正确显示。我能做什么?您是否在页面上设置了内容类型元标记 编辑: 为了解决你在评论中的问题,我可能会这样做(超级快速和肮脏): 话虽如此,正确的方法是解析由curl\u exec返回的HTML,找到适当的节点(使用name=“description”)并返回content属性的urlencoded值,如果设置为

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

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

编辑

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



话虽如此,正确的方法是解析由
curl\u exec
返回的HTML,找到适当的节点(使用
name=“description”
)并返回
content
属性的
urlencode
d值,如果设置为UTF-8。当我不应用任何内容时,字符串返回正确编码的UTF-8字符,但磅符号除外。您尝试过HTML编码吗?该字符的代码为£;如何从这些站点正确检索元描述:
http://cn.atpworldtour.com/Tennis/Tournaments/London-Finals.aspx
http://pravda.ru
http://www.dailymail.co.uk/health/article-1374575/Under-18s-sunbed-ban-cut-skin-cancer-toll.html
同时保留字符的格式
<?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]);

?>