#include <windows.h> // Standard Window header required for all programs
char * wchar2char(const wchar_t* wchar)
{
char * m_char;
int len = WideCharToMultiByte(CP_ACP, 0, wchar, wcslen(wchar), NULL, 0, NULL, NULL);
m_char = new char[len + 1];
WideCharToMultiByte(CP_ACP, 0, wchar, wcslen(wchar), m_char, len, NULL, NULL);
m_char[len] = '\0';
return m_char;
}
wchar_t * char2wchar(const char* cchar)
{
wchar_t *m_wchar = new wchar_t[strlen(cchar) + 1];
MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), m_wchar, strlen(cchar));
m_wchar[strlen(cchar)] = L'\0';
return m_wchar;
}
c++编程--wchar_t *与char *相互转换
最新推荐文章于 2024-10-05 18:47:55 发布