T
Thomas Jespersen
Hello
This question has been asked many times, but I haven't been able to find a
solution which works.
When I use System.Net.HttpWebRequest.GetResponse.GetResponseStream to read
the response from a posted form, the result is decoded automatically.
How do I specify that GetResponseStream should use "iso-8859-1" when
decoding?
Some background:
My response includes the Danish characters ÆØÅæøå but xml-encoded like this:
øæåØÆÅ. When I read the response using the
following code the response includes questionmarks (?) instead of the Danish
letters.
[CODE START]
Dim encoding As New System.Text.ASCIIEncoding
Dim requestByte As Byte() = encoding.GetBytes("myXMLRequest")
Dim httpWebRequest As System.Net.HttpWebRequest
httpWebRequest = System.Net.HttpWebRequest.Create("http://10.0.0.1")
httpWebRequest.Method = "POST"
httpWebRequest.ContentType = "application/x-www-form-urlencoded"
Dim requestStream As System.IO.Stream = httpWebRequest.GetRequestStream()
requestStream.Write(requestByte, 0, requestByte.Length)
requestStream.Close()
Dim streamReader As New
System.IO.StreamReader(httpWebRequest.GetResponse.GetResponseStream,
System.Text.Encoding.GetEncoding("iso-8859-1"))
Dim responseString As String = streamReader.ReadToEnd()
[CODE END]
This is driving me mad... please help.
Best. regards.
Thomas Jespersen
Mentum, Denmark
MCSE+I, MCSD, MCP+SB, MCT
This question has been asked many times, but I haven't been able to find a
solution which works.
When I use System.Net.HttpWebRequest.GetResponse.GetResponseStream to read
the response from a posted form, the result is decoded automatically.
How do I specify that GetResponseStream should use "iso-8859-1" when
decoding?
Some background:
My response includes the Danish characters ÆØÅæøå but xml-encoded like this:
øæåØÆÅ. When I read the response using the
following code the response includes questionmarks (?) instead of the Danish
letters.
[CODE START]
Dim encoding As New System.Text.ASCIIEncoding
Dim requestByte As Byte() = encoding.GetBytes("myXMLRequest")
Dim httpWebRequest As System.Net.HttpWebRequest
httpWebRequest = System.Net.HttpWebRequest.Create("http://10.0.0.1")
httpWebRequest.Method = "POST"
httpWebRequest.ContentType = "application/x-www-form-urlencoded"
Dim requestStream As System.IO.Stream = httpWebRequest.GetRequestStream()
requestStream.Write(requestByte, 0, requestByte.Length)
requestStream.Close()
Dim streamReader As New
System.IO.StreamReader(httpWebRequest.GetResponse.GetResponseStream,
System.Text.Encoding.GetEncoding("iso-8859-1"))
Dim responseString As String = streamReader.ReadToEnd()
[CODE END]
This is driving me mad... please help.
Best. regards.
Thomas Jespersen
Mentum, Denmark
MCSE+I, MCSD, MCP+SB, MCT