您的位置:首页 > 编程语言 > C语言/C++

c c++中Unicode和AscII进行转化

2012-04-13 10:39 288 查看
WideToAsc(wchar_t *wp,char *p)

{

bool ret = false;

if(wp != NULL)

{

int count = WideCharToMultiByte(CP_ACP,0,wp,-1,0,0,NULL,NULL);

if(count > 0)

{

WideCharToMultiByte(CP_ACP, 0, wp, -1, p, count + 1 , NULL, NULL);

p[count] = '\0';

ret = true;

}

}

return ret;

}

AscToWide(char *p,wchar_t *wp)

{

bool ret = false;

if(p != NULL)

{

int count = MultiByteToWideChar(CP_ACP, 0, p , strlen(p), NULL , 0);

if(count > 0)

{

MultiByteToWideChar(CP_ACP, 0, p , strlen(p), wp , count+1);

wp[count] = '\0';

ret = true;

}

}

return ret;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: