关于UNICODE转化成UTF8和POST
来源:互联网 发布:node.js和js 编辑:程序博客网 时间:2024/05/20 05:10
为这点小事也能郁闷。。
注意参数:
WideCharToMultiByte(CP_UTF8, 0, pszValue, -1, buf, 255, NULL, NULL );
BOOL result = FALSE;
CInternetSession session;
CHttpFile* pFile;
CHttpConnection* pConnection;
try
{
char strUtf8Req[512];
memset( strUtf8Req, 0, 512);
WCHAR* strWchar;
strWchar = request.GetBuffer();
string str;
GetAnsiString( str, strWchar);
strcpy( strUtf8Req, str.c_str() );
CString strServerName = _T("a.b.c.d:8080");
CString strFormAction = _T("/xx/api/xxxxx");
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
pConnection = session.GetHttpConnection(strServerName);
if( pConnection == NULL)
return FALSE;
pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, strFormAction);
if( pFile == NULL)
return FALSE;
//result = pFile->SendRequest( strHeaders, (void*)strFormData, strlen(strFormData) );
result = pFile->SendRequest( strHeaders, (void*)strUtf8Req, strlen(strUtf8Req) );
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);
if( dwRet == HTTP_STATUS_OK)
{
CString responseUtf8;
CString strLine;
while(pFile->ReadString(strLine))
{
responseUtf8 += strLine;
}
char* strUtf8 = (char*)responseUtf8.GetBuffer();
result = ParseResponse(strUtf8, response);
responseUtf8.ReleaseBuffer();
}
pFile->Close();
session.Close();
pConnection->Close();
}
catch (CInternetException* e)
{
pFile->Close();
session.Close();
pConnection->Close();
CString s;
s.Format(_T("Internet Exception/r/nm_dwError%u,m_dwContextError%u"),e->m_dwError,e->m_dwContext);
AfxMessageBox(s);
return FALSE;
}
return result;
- 关于UNICODE转化成UTF8和POST
- unicode to utf8 转化
- 关于unicode和utf8,utf16等
- perl 转化 utf8/unicode/gb2312
- Unicode与UTF8相互转化
- 转码utf8 - unicode 和 unicode - utf8
- Unicode,Ansi和UTF8
- UTF8 、unicode 和 Ascii2
- utf8 和unicode关系
- Unicode和UTF8
- 关于unicode、utf8、utf16、gb2312和GBK的一些理解
- 关于unicode、utf8、utf16、gb2312和GBK的一些理解
- 关于char wchar_t 和 unicode utf8等混淆概念
- ANSI、Unicode、UTF8相互转化的函数
- GB2312和BIG5,Unicode/UTF8等编码之间的互相转化
- 读写Unicode和UTF8格式文件
- Gb2312和Utf8 转为 Unicode
- unicode和utf8的关系
- 营销10大常见弊端
- 在Struts2中使用JasperReports生成报表(一)
- linux设置环境变量(转)
- oracle 9.2.0.4 在linux as4上安装
- C# Windows 窗体的.Net 框架绘图技术
- 关于UNICODE转化成UTF8和POST
- 在Struts2中使用JasperReports生成报表(二)
- 一个TIF文件包含多个文件,如何显示每一张图片
- query中附加数据表的作用
- ubnutu 安装openssh-server 连接 secure CRt
- 一行代码解决iframe挂马(包含服务器端注入、客户端ARP注入等)
- 二行代码解决全部网页木马(含iframe/script木马)
- 美国通信卫星与俄罗斯已报废卫星相撞
- WinCE OAL中的OEMInit函数