For some reason the data is sended non UTF encoded and then it fails. But why does it do that?
Obviously it's the XMLHTTP ActiveX object doing something weird with the WinInet API, because it affects whole process and not just its own HINTERNET. However you can specify that you are always going to push the host/path/query data in UTF-8, and you don't want anyone meddling with it, using the following code: DWORD value = CP_UTF8;
InternetSetOptionA(hInternet, INTERNET_OPTION_CODEPAGE, &value, sizeof(value));
InternetSetOptionA(hInternet, INTERNET_OPTION_CODEPAGE_PATH, &value, sizeof(value));
InternetSetOptionA(hInternet, INTERNET_OPTION_CODEPAGE_EXTRA, &value, sizeof(value));
It makes the encoding problem go away, at least here on Win7/x64.
Note you probably shouldn't be very strict in checking the return values here (well not that your current code does...), because according to MSDN, there are some limitations for those flags:Windows XP with SP2 and Windows Server 2003 with SP1: This flag is not supported.
Version: Requires Internet Explorer 7.0.