gSoap中文乱码解决

// 宽 字符转UTF8 
string EncodeUtf8(wstring in) 
{ 
	string s(in.length()*3+1,' '); 
	size_t len = ::WideCharToMultiByte(CP_UTF8, 0, 
		in.c_str(), in.length(), 
		&s[0], s.length(), 
		NULL, NULL); 
	s.resize(len); 
	return s; 
} 


// UTF8 转宽字符 
wstring DecodeUtf8(string in) 
{ 
	wstring s(in.length(), _T(' ')); 
	size_t len = ::MultiByteToWideChar(CP_UTF8, 0, 
		in.c_str(), in.length(), 
		&s[0], s.length()); 
	s.resize(len); 
	return s; 
} 

void CcxfwsDlg::testhelloservice()
{


	HelloServiceSoapBindingProxy service ;


	soap_set_mode(service.soap,SOAP_C_UTFSTRING);


	ns1__testgetStrings ar;
	struct soap *mydata;
	ns1__testgetStringsResponse re;
	service.testgetStrings(&ar,&re);
	char** s = re.return_;
	int size = re.__sizereturn_;


	list<wstring> strgets;


	for(int index = 0; index < size; index++) {	
		char *value = s[index];	
		string values = s[index];	
		wstring temp = DecodeUtf8(s[index]);
		strgets.push_back(temp);
	}


	service.destroy();
	//OnOK();
}



你可能感兴趣的:(gSoap中文乱码解决)