summaryrefslogtreecommitdiff
path: root/Source/Core/Common/CommonFuncs.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-12-29 19:48:00 +0100
committerGitHub <noreply@github.com>2023-12-29 19:48:00 +0100
commitbf0ac9de0ccf004b86ccadd0a0212fc6804d7600 (patch)
treed19fe3d878034837a113dfb92e9b55fa7b5ca084 /Source/Core/Common/CommonFuncs.cpp
parent68250afa08ab61b1214f32089ba5b250d590db60 (diff)
parent0c7359e150f609f054f805723ede91f94e7cf344 (diff)
Merge pull request #12466 from JosJuice/win32-error-string-encoding
Common: Fix encoding handling in GetWin32ErrorString
Diffstat (limited to 'Source/Core/Common/CommonFuncs.cpp')
-rw-r--r--Source/Core/Common/CommonFuncs.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/Core/Common/CommonFuncs.cpp b/Source/Core/Common/CommonFuncs.cpp
index 0a546428b7..aff87a9258 100644
--- a/Source/Core/Common/CommonFuncs.cpp
+++ b/Source/Core/Common/CommonFuncs.cpp
@@ -10,7 +10,10 @@
#ifdef _WIN32
#include <windows.h>
+
#define strerror_r(err, buf, len) strerror_s(buf, len, err)
+
+#include "Common/StringUtil.h"
#endif
namespace Common
@@ -59,11 +62,11 @@ std::string GetLastErrorString()
// Like GetLastErrorString() but if you have already queried the error code.
std::string GetWin32ErrorString(DWORD error_code)
{
- char error_message[BUFFER_SIZE];
+ wchar_t error_message[BUFFER_SIZE];
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error_code,
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error_code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error_message, BUFFER_SIZE, nullptr);
- return std::string(error_message);
+ return WStringToUTF8(error_message);
}
// Obtains a full path to the specified module.