inline wchar_t *AnsiToUnicode(const char *szStr) { if (szStr == NULL) return NULL; int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0); if (nLen == 0) { return NULL; } wchar_t *pResult = new wchar_t[nLen]; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen); return pResult; } /*---------------------------------------------------------------------------------- * 字符串转换函数 (wchar_t *) --> (char *) * 将宽字节 wchar_t* 转换 单字节char* *-----------------------------------------------------------------------------------*/ inline char *UnicodeToAnsi(const wchar_t * szStr) { if (szStr == NULL) return NULL; int nLen = WideCharToMultiByte(CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL); if (nLen == 0) { return NULL; } char *pResult = new char[nLen]; WideCharToMultiByte(CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL); return pResult; }