카테고리 없음

wchar to char 변환

희황 2020. 3. 23. 12:41

char * SDKDemo::ConvertWCtoC(wchar_t* str)

//wchar을 char로 변경

{

char* pStr ;
int strSize = WideCharToMultiByte(CP_ACP, 0,str,-1, NULL, 0,NULL, NULL);
pStr = new char[strSize];
WideCharToMultiByte(CP_ACP, 0, str, -1, pStr, strSize, 0,0);

return pStr;

}

 

 

wchar_t* SDKDemo::ConverCtoWC(char* str)

//char을 wchar로 변경

{

wchar_t* pStr;
int strSize = MultiByteToWideChar(CP_ACP, 0,str, -1, NULL, NULL);
pStr = new WCHAR[strSize];
MultiByteToWideChar(CP_ACP, 0,str, strlen(str)+1, pStr, strSize);

return pStr;

}

 

함수의 반환값은 쓴 후 delete 해줘야함.