I made my own rss feed with php, but I cannot get it validated when I use accented characters. I can't find a solution for that.
This is my RSS feed until now:
<?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>
I tried the CDATA tag, and it fixed special characters, but not the accented. Any thoughts?
I used: https://validator.w3.org/feed/check.cgi as validator. Error message: "'utf8' codec can't decode byte 0xe9 in position 2474: invalid continuation byte (maybe a high-bit character?)"
And I check in my Firefox and IE browsers, it just doesn't show the item with the accented character. Other items within the whole feed are displayed just fine.
This is the header info:
header('Content-type: text/xml; charset=utf-8');
I found the answer myself.
Make sure you use utf8_encode() to get the accented character right.
Example:
$title = Beyoncé;
$title = utf8_encode($title);
echo $title