Вот мой код:Получение текста из веб-запроса
Uri myUri = new Uri("my url");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (myUri);
// Set some reasonable limits on resources used by this request
request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
// Set credentials to use for this request.
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine ("Content length is {0}", response.ContentLength);
Console.WriteLine ("Content type is {0}", response.ContentType);
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
Console.WriteLine ("Response stream received.");
Console.WriteLine (readStream.ReadToEnd());
response.Close();
readStream.Close();
Response должно быть что-то вроде этого:
[
{
"book_name": "CYRILLIC LETTERS",
"book_id": "Text",
},
{
"book_name": "CYRILLIC LETTERS",
"book_id": "Text",
},
]
StreamReader.ReadToEnd() возвращает все, что я хочу, но замена кириллицы письма к цифрам, например: \ u041c \ u0410 \ u0422 \ u0422 \ u041e
Что мне делать, чтобы иметь возможность правильно все правильно?
Если я поменяю его на кодировку на Unicode, тогда все будет вопросительным знаком. – Dilshod
Ваш первый пример показывает все как знак вопроса, а второй показывает «System.IO.StreamReader». Вы пробовали это на своем компьютере? – Dilshod
моя ошибка во-первых, я попробовал это на своем компьютере, но использовал только простую струнную кириллицу и работал – juniordeveloper