Помогите в C#

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by enk, 12 May 2011.

  1. enk

    enk New Member

    Joined:
    21 Feb 2011
    Messages:
    9
    Likes Received:
    1
    Reputations:
    0
    Code:
    System.Net.WebRequest reqGET = System.Net.WebRequest.Create(@"http://site.ru/");
    System.Net.WebResponse resp = reqGET.GetResponse();
    System.IO.Stream stream = resp.GetResponseStream();
    System.IO.StreamReader sr = new System.IO.StreamReader(stream);
    string s = sr.ReadToEnd();
    Console.WriteLine(s);
    этот код почему-то выводит русские символы знаками вопроса! помогите что не так?! :confused: :confused: :confused:
     
  2. X-rus

    X-rus Member

    Joined:
    22 Dec 2010
    Messages:
    88
    Likes Received:
    22
    Reputations:
    4
    Попробуй:
    Code:
    System.IO.StreamReader sr = new System.IO.StreamReader(stream, Encoding.Default);
    
     
  3. seosimf

    seosimf Member

    Joined:
    3 Mar 2011
    Messages:
    271
    Likes Received:
    44
    Reputations:
    6
    Читаешь кодировку из ответа:
    и дальше как писали выше.