Я пытаюсь напечатать текст в моем окне на C ++. Но вместо этого он показывает странные китайские символы.
Пример
wstring s2ws(const std::string& s);
wstring tempConsole = s2ws(console);
string* consolePointer = NULL;
string console = "Unable to open file";
consolePointer = &console;//malloc(sizeof(string));
tempConsole = s2ws(*consolePointer);
LPCWSTR result = tempConsole.c_str();
TextOut(hdc, 10, 1580, TEXT(result), 19);
InvalidateRect(hWnd, NULL, TRUE);
wstring s2ws(const std::string& s)
{
int len;
int slength = (int)s.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
wstring r(buf);
delete[] buf;
return r;
}
Я ожидал «Невозможно открыть файл» в качестве вывода, но получил странные китайские символы.