int CUtility::UTF_8ToAnsi(const char* pSrc, char* pDest, int nOut)
{
int ret;
wchar_t *wc;
char *Temp;
wc = (wchar_t*)malloc(sizeof(wchar_t)*(nOut+1));
memset(wc,0,sizeof(wchar_t)*(nOut+1));
if(nOut==0)
{
free(wc);
return ::MultiByteToWideChar( CP_UTF8, 0, pSrc, -1, NULL, 0);
}
else
{
ret = ::MultiByteToWideChar( CP_UTF8, 0, pSrc, nOut, wc, nOut+1); // UTF-8 to UCS-2
USES_CONVERSION;
Temp = W2A( wc ); // UCS-2 to ANSI
memcpy(pDest,Temp,nOut);
free(wc);
return ret;
}
}