C언어,ARM

ANSI 유니코드 문자열 코드 변환 쉽게

안녕1999 2020. 9. 19. 23:55
void strcpy_wc(wchar_t *buf, char *s)
{
	int nLen = MultiByteToWideChar(CP_ACP,
		0,
		s, -1,
		NULL,
		NULL);

	MultiByteToWideChar(CP_ACP,
		0,
		s, -1,
		buf,
		nLen);
}
void strcpy_cw(char *buf, wchar_t *s)//max=1024
{
	if (buf)if (s)
	{
		WideCharToMultiByte(CP_ACP,
			0,
			s, -1,
			buf, 1024,
			NULL,
			NULL);
	}
}
void strcat_wc(wchar_t *buf, char *s)
{
	if (buf)if (s)
	{
		while (*buf)buf++;
		int nLen = MultiByteToWideChar(CP_ACP,
			0,
			s, -1,
			NULL,
			NULL);

		MultiByteToWideChar(CP_ACP,
			0,
			s, -1,
			buf,
			nLen);
	}
}
void strcat_cw(char *buf, wchar_t *s)//max=1024
{
	if (buf)if (s)
	{
		WideCharToMultiByte(CP_ACP,
			0,
			s, -1,
			buf, 1024,
			NULL,
			NULL);
	}
}