大虾在哪里,尝试在c++里多字节字符串转BSTR,然后再转回字符串,两次转换后,结果有误啊...
求解....
代码如下:
const UCHAR temp[17] = {0x89, 0x3d, 0xd8, 0x61, 0x67, 0x09, 0xd3,
0x4a, 0xeb, 0xe4, 0xaf, 0x46, 0xa3, 0xea, 0x56, 0xee,'\0'};
string ss ;
ss.append((const char*)temp);
int nLength =(ss.length()+1)*sizeof(wchar_t);
LPOLESTR wcharTemp =(OLECHAR*)new LPOLESTR[nLength];
AnsiToUnicode(ss.c_str(),wcharTemp);
BSTR bstrTemp = ::SysAllocString(wcharTemp);
//*pVal = bstrTemp;
char *pTemp = _com_util::ConvertBSTRToString(bstrTemp);
string ss2 = pTemp;
delete pTemp;
pTemp = NULL;