|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by digitalpacman in Programming for ASP.NET, C# Programming Language, RSS
Problem:
I can't seem to write the proper character encoding from an RSS feed.
I need to read the RSS feed (this works) and then format the feed into HTML and write the HTML along with the proper character encoding so the browser can display special characters properly.
For example I need to read a Shift_JIS RSS and then know it is Shift_JIS so that I can print out "Shift_JIS" to the charset header and/or the <meta> tag for content type.
I am using C#. I have code that works on one feed, but when I change the source all of a sudden the character encoding becomes NULL.
1:
2:
3:
4:
5:
6:
7:
8:
|
XmlTextReader textReader = new XmlTextReader(rssUrl);
XmlReader xmlReader = null;
SyndicationFeed feed = null;
xmlReader = XmlReader.Create(textReader, new XmlReaderSettings());
feed = SyndicationFeed.Load(xmlReader);
feedEncoding = textReader.Encoding.WebName; // This sometimes errors
context.Response.Charset = feedEncoding;
|
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625