반응형

아래 코드는 char 문자열을 wchar_t 문자열로 

wchar_t 문자열을 char 문자열로 바꿔주는 코드이다 

 

#include <stringapiset.h>

void char_to_wchar(const char* input_str, wchar_t* output_wstr)
{
	int strSize = MultiByteToWideChar(CP_UTF8, 0, input_str, -1, NULL, NULL);
	MultiByteToWideChar(CP_UTF8, 0, input_str, strlen(input_str) + 1, output_wstr, strSize);
}


void wchar_to_char(const wchar_t* input_wstr, char* output_str)
{
	int strSize = WideCharToMultiByte(CP_UTF8, 0, input_wstr, -1, NULL, 0, NULL, NULL);
	WideCharToMultiByte(CP_UTF8, 0, input_wstr, -1, output_str, strSize, 0, 0);
}
반응형

+ Recent posts