- What character encoding is used by
StreamReader.ReadToEnd()
? - What would be the reason to use (b) instead of (a) below?
- Is there a risk of their being a character encoding problem if (a) is used instead of (b)?
- Is there another method that is better than (a) and (b)?
(a)
Dim strWebResponse As String
Dim Request As HttpWebRequest = WebRequest.Create(Url)
Using Response As WebResponse = smsRequest.GetResponse()
Using reader As StreamReader = New StreamReader(Response.GetResponseStream())
strWebResponse = reader.ReadToEnd()
End Using
End Using
(b)
Dim encoding As New UTF8Encoding()
Dim strWebResponse As String
Dim Request As HttpWebRequest = WebRequest.Create(Url)
Using Response As WebResponse = Request.GetResponse()
Dim responseBuffer(Response.ContentLength - 1) As Byte
Response.GetResponseStream().Read(responseBuffer, 0, Response.ContentLength - 1)
strWebResponse = encoding.GetString(responseBuffer)
End Using