Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:17:14+00:00 2026-06-14T04:17:14+00:00

What character encoding is used by StreamReader.ReadToEnd() ? What would be the reason to

  • 0
  • 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:17:16+00:00Added an answer on June 14, 2026 at 4:17 am

    The standard encoding used by StreamReader is Encoding.Default, which will vary from machine to machine depending on your version of Windows and the locale that you have set. Encoding.UTF8.

    I have trouble remembering what the defaults are, so I prefer to use the StreamReader constructor that lets me specify the encoding. For example:

    Using reader As StreamReader = New StreamReader(Response.GetResponseStream(), Encoding.UTF8)
    

    See the constructor documentation for more info.

    If you use that constructor in your example a, the results will be the same as for your example b.

    Should you use UTF-8? That depends on the page you’re downloading. If the page you’re downloading was encoded with UTF-8 then, yes, you should use UTF-8. UTF-8 is supposed to be the default if no character set is defined in the HTTP headers. But you need to check the Content-Type header to determine if the page uses some other encoding. For example, the Content-Type header might read:

     application/xml; charset=ISO-8859-2
    

    You would have to examine the ContentType property of the HttpWebResponse, check to see if there is a charset field, and set the encoding properly based on that.

    Or, just use UTF-8 and hope for the best.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing character encoding problem while using @ResponseBody annotation. If I use response.getWriter().write() method
is there any other way to know if the java String contains character-encoding in
UTF-8 is an encoding used to represent the Unicode Character set . Other encodings
I have read that its bad idea to use platform default character encoding for
What is the default character encoding of the Android system? Which Charset is used?
What is the difference between mblen and strlen? Is today multi-byte character encoding used
All, Im having the age old problem with character encoding... I have a mySQL
It seems to me if UTF-8 was the only encoding used everywhere ever, there
How do I properly set the default character encoding used by the JVM (1.5.x)
I want to centralize as possible the character encoding used by my JSF pages.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.