From ad59c7f46d1301db24d6fcad09f61f9c780d66fd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 3 Dec 2012 07:44:29 -0800 Subject: [PATCH 1/2] Convert the title to wchars to fix non-ASCII. --- Windows/WindowsHost.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 9c56f14567..85b317c6c4 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -40,7 +40,27 @@ void WindowsHost::SetWindowTitle(const char *message) // Really need a better way to deal with versions. std::string title = "PPSSPP v0.4 - "; title += message; - SetWindowText(mainWindow_, title.c_str()); + + int size = MultiByteToWideChar(CP_UTF8, 0, message, title.size(), NULL, 0); + if (size > 0) + { + wchar_t *utf16_title = new wchar_t[size + 1]; + if (utf16_title) + size = MultiByteToWideChar(CP_UTF8, 0, message, title.size(), utf16_title, size); + else + size = 0; + + if (size > 0) + { + utf16_title[size] = 0; + SetWindowTextW(mainWindow_, utf16_title); + delete[] utf16_title; + } + } + + // Something went wrong, fall back to using the local codepage. + if (size <= 0) + SetWindowTextA(mainWindow_, title.c_str()); } void WindowsHost::InitSound(PMixer *mixer) From 346095d5f085984d80b6d9b0589c8afd2931b9cd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 3 Dec 2012 07:57:28 -0800 Subject: [PATCH 2/2] SetWindowText() was doing ANSI conversion. --- Windows/WindowsHost.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 85b317c6c4..7dc6b109ee 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -53,7 +53,8 @@ void WindowsHost::SetWindowTitle(const char *message) if (size > 0) { utf16_title[size] = 0; - SetWindowTextW(mainWindow_, utf16_title); + // Don't use SetWindowTextW because it will internally use DefWindowProcA. + DefWindowProcW(mainWindow_, WM_SETTEXT, 0, (LPARAM) utf16_title); delete[] utf16_title; } }