BSTR 转换到 UTF
static int BSTR2UTF8(BSTR bstrIn, char **pszOut)
{
int cbSize = WideCharToMultiByte(CP_UTF8, 0, bstrIn, SysStringLen(bstrIn)+1, 0, 0, 0, 0);
*pszOut = (char*) malloc(cbSize);
assert(*pszOut);
return WideCharToMultiByte(CP_UTF8, 0, bstrIn, SysStringLen(bstrIn)+1, *pszOut, cbSize, 0, 0);
}
// 测试
void main( void )
{
CComBSTR bstrIn(L"myCode={{shang上海160!}}");
char *psz = 0;
int len = BSTR2UTF8(bstrIn, &psz);
wchar_t wsz[200];
int nn = MultiByteToWideChar(CP_UTF8, 0, psz, len, wsz, 200);
free(psz);
}