I need to POST a normal-everyday XML data string to a website.
I FAIL when I POST with WinInet using:
I SUCCEED when I POST with IXMLHTTPRequest using:Code:
string Headers="Content-Type: application/xml";
string POSTdata="<?xml version=\"1.0\" encoding=\"utf-8\"?><note><to>Webserver</to><from>Me</from><re>My XML data</re></note>";
HttpSendRequest(hReq, Headers.c_str(), (DWORD)-1, (LPVOID)POSTdata.c_str(), strlen(POSTdata.c_str()))
I read that IXMLHTTPRequest encodes the XML to UTF-8:Code:
send Method (IXMLHTTPRequest)
But, I am not sure if WinInet can even encode to UTF-8:Quote:
If the input type is an XML DOM object, the response is encoded according to the encoding attribute on the <? declaration in the document. If there is no XML declaration or encoding attribute, UTF-8 is assumed.
Issue in sending HTTP Request with UTF-8 URI using WinINet
For me though, here is why I am confused:Quote:
It would be very helpful if I can get any documentation stating that Windows APIs don't support UTF-8.
UTF-8 - Wikipedia, the free encyclopedia
So, what is the difference?Quote:
The first 128 characters of Unicode, which correspond one-to-one with ASCII, are encoded using a single octet with the same binary value as ASCII, making valid ASCII text valid UTF-8-encoded Unicode as well.
Byte versus Byte, character versus character.
Shouldn't my XML string be the same in UTF-8 versus the original C++ string?
If the answer is: "Yes, they should be the same" - then, why does WinInet FAIL?
If the answer is: "No, they are actually different" - then, what does my XML look like in UTF-8?