我使用php创建了自己的RSS源,但是当我使用重音字符时,我无法验证它。我无法找到解决方案。
这是我的RSS Feed,直到现在:
<?xml version="1.0"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>My site</title>
<link>http://www.example.com</link>
<description>The newest music</description>
<atom:link href="http://www.example.com/feed.php" rel="self"></atom:link>
<item>
<title><![CDATA[Beyoncé - Sorry]]></title>
<description>New Music</description>
<pubDate>Thu, 23 Jun 2016 09:07:10 +0000</pubDate>
<guid>http://www.example.com/beyonce/sorry</guid>
<enclosure url="mypicture.jpg" length="0" type="image/jpeg"></enclosure>
<link>http://www.example.com/beyonce/sorry</link>
</item>
</channel>
</rss>
我尝试了CDATA标签,它修复了特殊字符,但没有重音。 有什么想法吗?
我使用:https://validator.w3.org/feed/check.cgi作为验证器。 错误讯息:&#34;&#39; utf8&#39;编解码器不能解码2474位的字节0xe9:无效的连续字节(可能是高位字符?)&#34;
我在我的Firefox和IE浏览器中查看,它只是没有显示带有重音字符的项目。整个Feed中的其他项目显示得很好。
这是标题信息:
header('Content-type: text/xml; charset=utf-8');
答案 0 :(得分:0)
我自己找到了答案。
确保使用utf8_encode()来获得重音字符。
示例:
$title = Beyoncé;
$title = utf8_encode($title);
echo $title