我正在尝试发出网络请求并用希伯来语发送帖子数据,但服务器端却像“?????” 而不是希伯来语。
WebRequest request = WebRequest.Create(MyserverClient.Url + Constants.TaskUpdatePropertyURL);
((HttpWebRequest)request).AllowAutoRedirect = false;
((HttpWebRequest)request).KeepAlive = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;";
request.Headers.Add("Pragma: no-cache");
request.Headers.Add(string.Format("Cookie: {0}", Client.phpId));
request.Headers.Add(string.Format("requesttoken: {0}", requestToken));
string postData = "Some Non-english text";
using (Stream dataStream = request.GetRequestStream())
{
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
}
try{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Get the stream containing content returned by the server.
Stream dataStream2 = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream2);
// Read the content.
responseFromServer = reader.ReadToEnd ();
}
return responseFromServer;
}
正如我所说,对于非英语服务器,将帖子数据获取为“???????-?????????????” 但我应该对“一些非英文文本”有什么建议吗?