0
及彼的文字是我的代码:从Web请求
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();
的反应应该是这样的:
[
{
"book_name": "CYRILLIC LETTERS",
"book_id": "Text",
},
{
"book_name": "CYRILLIC LETTERS",
"book_id": "Text",
},
]
StreamReader.ReadToEnd()将返回我想要的一切,但它正在取代西里尔字母数字如:\ u041c \ u0410 \ u0422 \ u0422 \ u041e
我应该怎么做才能正确地得到一切?
如果我将它更改为Unicode的编码,那么一切都是问号。 – Dilshod 2015-01-21 05:29:41
您的第一个示例将所有内容显示为问号,第二个示例显示“System.IO.StreamReader”。你在电脑上试过这个吗? – Dilshod 2015-01-21 05:39:11
我的错误首先,我在我的电脑上试过这个,但只使用了一个简单的字符串西里尔字符串,并且作品 – juniordeveloper 2015-01-21 06:18:34