个人感觉ANSI -> UNICODE,编码方式为: 如ANSI 0X4A -> UNICODE 0X4A00 不知道对不?
两个UNICODE ANSI转换函数:
void UnicodeToAnsi(WCHAR* lpString,char *szAnsi)
{
size_t len = wcslen(lpString)*2;
char *buf = (char *)malloc(len);
size_t i = wcstombs(buf,lpString,len);
strcpy(szAnsi,buf);
free(buf);
}
void AnsiTounicode(LPCSTR lpString,WCHAR * lpUni)
{
PWSTR pWideCharStr; // 指向UNICODE字符串的指针
int nLenOfWideCharStr; // UNICODE字符串的长度
// 获取ANSI字符串的长度
nLenOfWideCharStr = MultiByteToWideChar(CP_ACP, 0, lpString, -1, NULL, 0);
pWideCharStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, nLenOfWideCharStr * sizeof(WCHAR));
// 转换ANSI字符串为UNICODE字符串
MultiByteToWideChar(CP_ACP, 0, lpString, -1, pWideCharStr, nLenOfWideCharStr);
wcscpy(lpUni,pWideCharStr);
// 释放分配的字符串
HeapFree(GetProcessHeap(), 0, pWideCharStr);
}