c c++中Unicode和AscII進行轉化

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;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章