HTTP POST数据时,一定要将数据转换为UTF8再调用HttpSendRequest!!!

问题:POST一个页面如http://127.0.0.1/post.php HTTP body为user=aaa&pass=bbb时,INTERNET_BUFFERS的dwBufferLength返回正确的长度17,但是lpReadBuff有时为空,有时为乱码

崩溃了,MSDN上看到这句话。。。

[code=html]Note  The HttpSendRequestA function represents headers as ISO-8859-1 characters not ANSI characters. The HttpSendRequestW function represents headers as ISO-8859-1 characters converted to UTF-16LE characters. As a result, it is never safe to use the HttpSendRequestW function when the headers to be added can contain non-ASCII characters. Instead, an application can use the MultiByteToWideChar and WideCharToMultiByte functions with a Codepage parameter set to 28591 to map between ANSI characters and UTF-16LE characters. [/code]
当时没细看这段话,原来我POST的字符串定义的是unicode,一定要转换成UTF8再调用HttpSendRequest!!!!错误诡异的很啊!!!
阅读更多
个人分类: 程序设计
上一篇ADO在C++中的使用
下一篇C++中explicit关键字的作用
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭