Finding myself annoyed at an RSS feed which was being rendered with the incorrect character encoding, I searched for the proper way to correct the output. I’m sure there are other ways to do it, but the following worked for me.
Using MagpieRSS, i’ve fetched the RSS feed and prepared it for output using a foreach loop. I used the PHP function utf8_encode()
to correctly render the charset.
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
print '<li class="rssfeeditem"><a href="' . $href .
'" target="_blank">' . utf8_encode($title) .'</a></li>';
}
Leave a Reply