I'm trying to send data to a PHP script from C#. The PHP page will insert the posted data to a database but the encoding needs to be UTF-8.
Here is the code from C#:
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
NameValueCollection data = new NameValueCollection();
string rq = "data here";
rq = Convert.ToBase64String(Encoding.UTF8.GetBytes(rq));
data["q"] = rq;
byte[] buffer=client.UploadValues("url of php file", "POST", data);
Code inside PHP file:
$data = $_POST["q"];
insert_to_database($data);
If data contains characters like é
or à
they will be inserted as Ä© Ä ....
.