//將Unicode字符轉成UTF8的char類型
//函數會爲pszDest分配合適的內存
//nDestLen轉換後結果的長度
BOOL String2Char(LPCWSTR pszStr, char *&pszDest, int &nDestLen)
{
int __len = WideCharToMultiByte(CP_UTF8, 0, pszStr, -1, NULL, 0, NULL, NULL);
if(__len > 0)
{
pszDest = new char[__len+1];
int nret = WideCharToMultiByte(CP_UTF8, 0, (pszStr), -1, (pszDest), __len, NULL, NULL);
return TRUE;
}
return FALSE;
}