2009年1月24日 星期六

天下文章一般抄 - Unicode 跟 Ansi 互轉

void Unicode2Ansi(TCHAR *unicode, char *ansi)
{
int n;
n = WideCharToMultiByte(CP_ACP, 0, unicode, -1, ansi, 0, NULL, FALSE);
WideCharToMultiByte(CP_ACP, 0, unicode, -1, ansi, n, NULL, FALSE);
}

void Ansi2Unicode(TCHAR *unicode, char *ansi)
{
int n;
n = MultiByteToWideChar(CP_ACP, 0, ansi, -1, 0, 0);
MultiByteToWideChar(CP_ACP, 0, ansi, -1, unicode, n);
}

沒有留言: