public string SendQuery(string query)
{
UTF8Encoding enc = new UTF8Encoding();
byte[] postdata = enc.GetBytes("query=" + query);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(SerUrl);
webRequest.CookieContainer = cookies;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = postdata.Length;
webRequest.Headers.Add(HttpRequestHeader.AcceptCharset, "UTF-8");
Stream stream = webRequest.GetRequestStream();
stream.Write(postdata, 0, postdata.Length);
stream.Close();
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
string ReturnData = reader.ReadToEnd();
return ReturnData;
}
PHP má výchozí kódování UTF-8. Když odešlu třeba "+ěščřžýá" a na php hned nechám poslat zpět - echo $_POST["query"] - tak mi to vypíše +???????;