Convert FormatMessage() to utf-8 to fix locale.

Otherwise we get non-utf-8 garbage if the user isn't in a Latin codepage.
This commit is contained in:
Unknown W. Brackets 2014-09-27 09:04:24 -07:00
parent 32fc4c7676
commit 42fe8ee32e

View File

@ -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 <string.h>
@ -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] = {};