2016-06-23 21 views
2

我做了我自己的RSS提要与PHP,但我不能验证当我使用重音字符。我找不到解决方案。PHP:RSS提要没有验证与重音字符存在

这是我的RSS提要直到如今

<?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作为验证器。 错误消息:“‘utf-8’编解码器不能在2474位置解码字节0xe9:(?也许一个高位字符)无效延续字节”

而且我查一下我的Firefox和IE浏览器,它只是没有按” t显示带有重音字符的项目。整个Feed中的其他项目都显示得很好。

这是头信息:

header('Content-type: text/xml; charset=utf-8'); 
+0

它验证对我蛮好。你在使用某种特定的验证方法吗?什么是错误?提供什么*不*工作,而不仅仅是工作。 – apokryfos

+0

我编辑了这篇文章,回答你的问题。 –

+0

我提供了什么不起作用。工作项目从上面的代码中删除。 –

回答

0

,我发现自己的答案。

确保您使用utf8_encode()来获取重音字符。

例子:

$title = Beyoncé; 
$title = utf8_encode($title); 

echo $title