在gsoap中处理编码问题

            在gsoap中,如果遇到编码问题,首先利用下面这个函数设置gsoap的接收的编码格式。如下例,把gsoap编码设置为UTF-8的格式:

            soap_set_mode(p_IASServer->soap, SOAP_C_UTFSTRING); 

            因此,您只需要把编码转换为UTF-8后传递给gsoap即可。

            例如 ANSI 与 UTF-8的互转

char*  ANSI2UTF8(char* szSource, bool bPositive)     // bPositive: 1 ansi to utf-8 , 1: utf-8 to ansi {   char* pszWideData, *pszReturn;  int   nlen = 0;  int   nFirstType = CP_ACP;  int   nSecondType = CP_UTF8;  if( !bPositive )  {   nFirstType = CP_UTF8;   nSecondType = CP_ACP;  }  if( !szSource || (strlen(szSource) == 0))  {   return NULL;  }  nlen = MultiByteToWideChar(nFirstType, 0, szSource, -1, NULL, 0);  pszWideData = new char [nlen * 2];  MultiByteToWideChar(nFirstType, 0, szSource, -1, (LPWSTR)pszWideData, nlen);

 nlen = WideCharToMultiByte(nSecondType, 0, (LPCWSTR)pszWideData, nlen, NULL, 0, NULL, FALSE);  pszReturn = new char[nlen];  WideCharToMultiByte(nSecondType, 0, (LPCWSTR)pszWideData, nlen, pszReturn, nlen, NULL, FALSE);

 delete [] pszWideData;  return pszReturn; }

           不过由于对GSoap还不是很熟悉,所以不知如何获取服务端返回的信息(以附件形式传送),有待进一步学习!!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值