Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Recieve ÅÄÖ with HttpWebRequest?

Recieve ÅÄÖ with HttpWebRequest?

Scheduled Pinned Locked Moved C#
helphtmltutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andreas Philipson
    wrote on last edited by
    #1

    Hi! I'm having a problem with the HttpWebRequest - when I recieve the stream it looses the ÅÄÖ (and some other...). The Code:

    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create ("http://www.dvdforum.nu");
    HttpWebResponse response = (HttpWebResponse)request.GetResponse ();

    StreamReader reader = new StreamReader (response.GetResponseStream ());
    StreamWriter writer = new StreamWriter ("google.html");

    string buffer = "";
    while ((buffer = reader.ReadLine ()) != null)
    {
    writer.WriteLine (buffer);
    }

    reader.Close ();
    writer.Close ();

    System.Diagnostics.Process.Start ("google.html");

    Any idea how to fix this? Andreas Philipson

    D A 2 Replies Last reply
    0
    • A Andreas Philipson

      Hi! I'm having a problem with the HttpWebRequest - when I recieve the stream it looses the ÅÄÖ (and some other...). The Code:

      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create ("http://www.dvdforum.nu");
      HttpWebResponse response = (HttpWebResponse)request.GetResponse ();

      StreamReader reader = new StreamReader (response.GetResponseStream ());
      StreamWriter writer = new StreamWriter ("google.html");

      string buffer = "";
      while ((buffer = reader.ReadLine ()) != null)
      {
      writer.WriteLine (buffer);
      }

      reader.Close ();
      writer.Close ();

      System.Diagnostics.Process.Start ("google.html");

      Any idea how to fix this? Andreas Philipson

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      You need to provide an System.Text.Encoder to StreamReader and StreamWriter to handle the conversion from bytes to chars (it's not the same thing in .NET). Which one will be some guesswork, but they are only 4 or 5. :) lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik

      A 1 Reply Last reply
      0
      • D Daniel Turini

        You need to provide an System.Text.Encoder to StreamReader and StreamWriter to handle the conversion from bytes to chars (it's not the same thing in .NET). Which one will be some guesswork, but they are only 4 or 5. :) lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik

        A Offline
        A Offline
        Andreas Philipson
        wrote on last edited by
        #3

        That was my first thought too, but none will give the right result :(. Andreas Philipson

        1 Reply Last reply
        0
        • A Andreas Philipson

          Hi! I'm having a problem with the HttpWebRequest - when I recieve the stream it looses the ÅÄÖ (and some other...). The Code:

          HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create ("http://www.dvdforum.nu");
          HttpWebResponse response = (HttpWebResponse)request.GetResponse ();

          StreamReader reader = new StreamReader (response.GetResponseStream ());
          StreamWriter writer = new StreamWriter ("google.html");

          string buffer = "";
          while ((buffer = reader.ReadLine ()) != null)
          {
          writer.WriteLine (buffer);
          }

          reader.Close ();
          writer.Close ();

          System.Diagnostics.Process.Start ("google.html");

          Any idea how to fix this? Andreas Philipson

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Try: StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("iso-8859-1"));

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups