std::wstring CharToWchar(const char* c, size_t encode = CP_ACP)
{
std::wstring str;
int len = MultiByteToWideChar(encode, 0, c, strlen(c), NULL, 0);
wchar_t* szBuf = new wchar_t[len + 1];
MultiByteToWideChar(encode, 0, c, strlen(c), szBuf, len);
szBuf[len] = '\0';
str = szBuf;
delete szBuf;
return str;
}
std::string WcharToChar(const wchar_t* wp, size_t encode = CP_ACP)
{
std::string str;
int len = WideCharToMultiByte(encode, 0, wp, wcslen(wp), NULL, 0, NULL, NULL);
char* szBuf = new char[len + 1];
WideCharToMultiByte(encode, 0, wp, wcslen(wp), szBuf, len, NULL, NULL);
szBuf[len] = '\0';
str = szBuf;
delete szBuf;
return str;
}