std::wstring wchart_arrayTowstring(wchar_t a[])
{
std::wstring wstr = L"";
int j = 0;
while (a[j] != L'\0')
{
wstr += a[j];
j++;
}
return wstr;
}
std::string wstringTostring(std::wstring wstr)
{
int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL);
if (len == 0)
return std::string("");
char* psz = new char[len];
if (!psz)
return std::string("");
WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, psz, len, NULL, NULL);
std::string str(psz);
delete[] psz;
psz = NULL;
return str;
}
wstring stringTowstring(string str)
{
int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
if (len == 0)
return wstring(L"");
wchar_t* wct = new wchar_t[len];
if (!wct)
return std::wstring(L"");
MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, wct, len);
wstring wstr(wct);
delete[] wct;
wct = NULL;
return wstr;
}
wchar_t* wstringToWcharArray(const std::wstring& str)
{
wchar_t* result = new wchar_t[str.length() + 1];
for (size_t i = 0; i < str.length(); i++) {
result[i] = str[i];
}
result[str.length()] = L'\0';
return result;
}