Re: how do I convert CStringW to UTF-8?
BOOL MultiByteToWideChar(wchar_t **ppDes , LPCSTR lpstrSource)
{
DWORD dwMinSize = MultiByteToWideChar (CP_UTF8, 0, lpstrSource, -1, NULL,
0);
wchar_t *pswText = new wchar_t[dwMinSize];
if(pswText==NULL)return FALSE;
if (MultiByteToWideChar(CP_UTF8, 0, lpstrSource, -1, pswText,
dwMinSize)==0)
{
delete []pswText;
pswText = NULL;
return FALSE;
}
*ppDes = pswText;
return TRUE;
}
BOOL WideCharToMultiByte(char **ppDes ,LPCWSTR lpstrSource)
{
DWORD dwMinSize = WideCharToMultiByte
(CP_UTF8,0,lpstrSource,-1,NULL,0,NULL,NULL);
char *psText = new char[dwMinSize];
if(psText==NULL)return FALSE;
if
(WideCharToMultiByte(CP_UTF8,0,lpstrSource,-1,psText,dwMinSize,NULL,NULL)==0)
{
delete []psText;
psText = NULL;
return FALSE;
}
*ppDes = psText;
return TRUE;
}
"alexl" <alextheblade@gmail.com>
??????:f3274b12-0044-447f-8430-c92926ef15dd@59g2000hsb.googlegroups.com...
hi,
how do I convert CStringW to UTF-8 for output into a CStringA or a
char* ?
thanks