I understand that the default encoding of an HTTP Request is ISO 8859-1.
Am I able to use Unicode to decode an HTTP request given as a byte array?
If not, how would I decode such a request in C#?
EDIT: I’m developing a server, not a client.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As you said the default encoding of an HTTP POST request is ISO-8859-1. Otherwise you have to look at the Content-Type header that might then look like
Content-Type: application/x-www-form-urlencoded; charset=UTF-8.Once you have read the posted data into a byte array you may decide to convert this buffer to a string (remember all strings in .NET are UTF-16). It is only at that moment that you need to know the encoding.
And to answer your question:
Yes, if unicode has been used to encode this byte array: