receiving XML content - ISO-8859-1

P

Piotrekk

Hi.
I receive XMLcontent codded in ISO-8859-1.
XML file contains Polish character set so that i need to notice somehow
when they are coming. My program cuts this characters and replaces them
with "". I have english copy of windows.
What am i dooing wrong here.
Any help would be appreciated
Thanks


try
{
HttpWebRequest request = null;
HttpWebResponse response = null;

request =
(HttpWebRequest)WebRequest.Create(address);

request.Headers.Clear();
request.ProtocolVersion = HttpVersion.Version11;

response = (HttpWebResponse)request.GetResponse();

string header2 = response.Headers.Get("Auth");
if (header2 != "true") throw MyException;

Stream responseStream =
response.GetResponseStream();
StreamReader streamReader = new
StreamReader(responseStream);

StreamWriter sw = new StreamWriter("~temp.xml");
string temp = null;

while (true)
{
temp = streamReader.ReadLine();
if (temp == null) break;
//HERE TEMP ALREADY HAS "" INSTEAD OF SPECIAL
CHARACTERS
sw.Write(temp);
}

response.Close();
sw.Close();
}
 
J

Jon Skeet [C# MVP]

Piotrekk said:
I receive XMLcontent codded in ISO-8859-1.
XML file contains Polish character set so that i need to notice somehow
when they are coming. My program cuts this characters and replaces them
with "". I have english copy of windows.
What am i dooing wrong here.

You're using StreamReader and StreamWriter, which use UTF-8 by default.
As you're only trying to dump the contents of the response stream to
disk, just use a stream directly.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top