RssReader.cs correction

Jan 23, 2014 at 9:06 PM
Hi,
I needed to correct the file RssReader.cs in order to convert the bytes array from UTF-8 to Ascii

public static class RssReader
{
    public static RssFeed Read(string url)
    {
        RssFeed rssFeed = null;

        WebClient myWebClient = new WebClient();
        byte[] rssBuffer = myWebClient.DownloadData(url);
        byte[] asciiArray = Encoding.Convert(Encoding.UTF8, Encoding.ASCII, rssBuffer);
        string rssText = Encoding.ASCII.GetString(asciiArray);

        using (TextReader s = new StringReader(rssText.Substring(1)))
        {
            var deserializer = new XmlSerializer(typeof(RssFeed));
            rssFeed = deserializer.Deserialize(s) as RssFeed;
        }
        return rssFeed;
    }
}