From 42fe8ee32e45c1f94cbb61ba66bfdbee425fc6a4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Sep 2014 09:04:24 -0700 Subject: [PATCH] Convert FormatMessage() to utf-8 to fix locale. Otherwise we get non-utf-8 garbage if the user isn't in a Latin codepage. --- Common/Misc.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Common/Misc.cpp b/Common/Misc.cpp index f5393cc1f9..5f80745b83 100644 --- a/Common/Misc.cpp +++ b/Common/Misc.cpp @@ -15,6 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include "util/text/utf8.h" #include "Common.h" #include @@ -44,14 +45,17 @@ const char *GetLastErrorMsg() } const char *GetStringErrorMsg(int errCode) { - static const size_t buff_size = 255; + static const size_t buff_size = 1023; #ifndef _XBOX #ifdef _WIN32 - static __declspec(thread) char err_str[buff_size] = {}; + static __declspec(thread) wchar_t err_strw[buff_size] = {}; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errCode, + FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - err_str, buff_size, NULL); + err_strw, buff_size, NULL); + + static __declspec(thread) char err_str[buff_size] = {}; + snprintf(err_str, buff_size, ConvertWStringToUTF8(err_strw).c_str()); #else static __thread char err_str[buff_size] = {};