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