bool WToAnsiChar(wchar_t *pSrcWchar, char **pOut, int &outLen)
{
bool bre = false;
if (NULL != pSrcWchar)
{
outLen = ::WideCharToMultiByte(CP_ACP, 0, pSrcWchar, -1, NULL, 0, NULL, NULL);
if (NULL != *pOut)
{
delete *pOut;
}
*pOut = new char[outLen + 1];
memset(*pOut, 0, outLen + 1);
::WideCharToMultiByte(CP_ACP, 0, pSrcWchar, -1, *pOut, outLen, NULL, NULL);
bre = true;
} while (false);
return bre;
}
bool AnsiCharToW(char *pSrcChar, wchar_t **pOut, int &outLen)
{
bool bre = false;
if (NULL != pSrcChar)
{
outLen = ::MultiByteToWideChar(CP_ACP, 0, pSrcChar, -1, NULL, 0);
if (NULL != *pOut)
{
delete *pOut;
}
*pOut = new wchar_t[outLen + 1];
memset(*pOut, 0, outLen + 1);
::MultiByteToWideChar(CP_ACP, 0, pSrcChar, -1, *pOut, outLen);
bre = true;
} while (false);
return bre;
}
bool WToUtf8Char(wchar_t *pSrcWchar, char **pOut, int &outLen)
{
bool bre = false;
if (NULL != pSrcWchar)
{
outLen = ::WideCharToMultiByte(CP_UTF8, 0, pSrcWchar, -1, NULL, 0, NULL, NULL);
if (NULL != *pOut)
{
delete *pOut;
}
*pOut = new char[outLen + 1];
memset(*pOut, 0, outLen + 1);
::WideCharToMultiByte(CP_UTF8, 0, pSrcWchar, -1, *pOut, outLen, NULL, NULL);
bre = true;
}
return bre;
}
bool Utf8CharToW(char *pSrcChar, wchar_t **pOut, int &outLen)
{
bool bre = false;
if (NULL != pSrcChar)
{
outLen = ::MultiByteToWideChar(CP_UTF8, 0, pSrcChar, -1, NULL, 0);
if (NULL != *pOut)
{
delete *pOut;
}
*pOut = new wchar_t[outLen + 1];
memset(*pOut, 0, outLen + 1);
::MultiByteToWideChar(CP_UTF8, 0, pSrcChar, -1, *pOut, outLen);
bre = true;
}
return bre;
}