|
-
Oct 10th, 2005, 02:46 AM
#1
Thread Starter
New Member
°C showing up as °C
I've written a program to read an rss feed for the weather and save the temperature into a text file, but when i view the text file in notepad it looks great eg. 14°C but when i view it under MS Word or Word Pad its coming up as 14°C.
Any ideas how to get rid of that  ?
If i need to post the code let me know, or if need any more info.
Thanks.
-
Oct 11th, 2005, 07:57 AM
#2
Re: °C showing up as °C
Show the line of code that is responsible for adding the degrees character.
I don't live here any more.
-
Oct 11th, 2005, 05:12 PM
#3
Thread Starter
New Member
Re: °C showing up as °C
I'll post the whole code.
Code:
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.Load("http://www.wunderground.com/auto/rss_full/global/stations/94821.xml");
System.Xml.XmlNode weather = xml.SelectSingleNode("/rss/channel/item/description");
string tempF = null;
string tempC = null;
if (weather != null)
{
string[] tokens = weather.InnerText.Split(" ".ToCharArray());
tempF = tokens[1];
tempC = tokens[3];
}
Console.WriteLine("Temperature F: " + tempF);
Console.WriteLine("Temperature C: " + tempC);
System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\weather.txt", false);
sw.WriteLine(tempC);
sw.Close();
sw = null;
-
Oct 17th, 2005, 03:39 AM
#4
Re: °C showing up as °C
So basically you are fetching the "°C" directly from the website's data stream.
Since "°" is a special character its likely that the "Â" is a prefix that identifies it as such. All you need to do is strip out the "Â" OR manually insert "°C" yourself.
Thre are numerous string functions available to handle this.
I don't live here any more.
-
Oct 17th, 2005, 05:09 PM
#5
Re: °C showing up as °C
just specify System.Text.Encoding.UTF8 in your StreamWriter. eg:
VB Code:
System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\weather.txt", false,[B]System.Text.Encoding.UTF8[/B]);
sw.WriteLine(tempC);
sw.Close();
sw = null;
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 19th, 2005, 12:31 PM
#6
Re: °C showing up as °C
 Originally Posted by wossname
So basically you are fetching the "°C" directly from the website's data stream.
Since "°" is a special character its likely that the "Â" is a prefix that identifies it as such. All you need to do is strip out the "Â" OR manually insert "°C" yourself.
Thre are numerous string functions available to handle this.
shut up you're wrong
listen to what dynamic_sysop said
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 19th, 2005, 05:51 PM
#7
Thread Starter
New Member
Re: °C showing up as °C
thanks for this, i'll give it ago soon!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|