0

In my Windows Phone application, I take RSS from Internet and I parse XML. I take out Title and Description from rss, and display them in a TextBlock.

Here I find some problems, the speacial characters are substituted by rhombus contain "?".

      /*CONNECTION AND DOWNLOAD RSS*/ 
        WebClient wc = new WebClient();
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(load_web_news);
        wc.DownloadStringAsync(new Uri("http://.../rssFeedNews.asp"));
        ....
     /*SAVE RSS*/
            TextBlock tbTitle = new TextBlock();
            Run rTitle = new Run();
            rTitle.Text = rss.Title;
            Run rDescription = new Run();
            rDescription.Text = rss.Description;
            tbTitle.Inlines.Add(rTitle);
        ....
       /*PARSING*/  
    private void load_web_news(object sender, DownloadStringCompletedEventArgs e)
    {
        XElement xmlitems = XElement.Parse(e.Result);
        List<XElement> elements = xmlitems.Descendants("item").ToList();
        foreach (XElement rssItem in elements)
                {
                    RSSItem rss = new RSSItem();
                    rss.Description1 = rssItem.Element("description").Value;
                    String title = rssItem.Element("title").Value;

How to display special chars for example "à" "è" "°" etc... in a WIndows phone app?

4

1 回答 1

2

WebClient 可能没有使用正确的编码来下载您的 rss 提要,请尝试将 Encoding 属性设置为正确的(可能是 Unicode?):

wc.Encoding = System.Text.Encoding.Unicode;

或者如果您知道使用了哪种特定编码:

wc.Encoding = System.Text.Encoding.GetEncoding("encoding name here") ;
于 2013-10-09T14:47:28.977 回答