我正在尝试进行网络请求并以希伯来语发送帖子数据 但服务器端得到它像“?????”而不是希伯来语。
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;
}
正如我所说,对于非英语的服务器获取帖子数据为“???? ???? ??????? ????”但我应该是“一些非英语文本” 任何建议??
答案 0 :(得分:4)
尝试这样的事情:
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
答案 1 :(得分:0)
您可以使用Uri.EscapeDataString(string)
答案 2 :(得分:-1)
也许这会做的工作: 在希伯来语中,
Encoding.GetEncoding(1255)