From dbe770d9210666a366f055d52b9f34fa8a3d7305 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 18 May 2025 14:39:10 +0100 Subject: [PATCH] Switch to ANSI Windows API in `Win32ErrorString()` function --- src/util/syserror.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/syserror.cpp b/src/util/syserror.cpp index a902826f8ec..4b456db8d07 100644 --- a/src/util/syserror.cpp +++ b/src/util/syserror.cpp @@ -12,8 +12,6 @@ #if defined(WIN32) #include -#include -#include #endif std::string SysErrorString(int err) @@ -41,16 +39,13 @@ std::string SysErrorString(int err) #if defined(WIN32) std::string Win32ErrorString(int err) { - wchar_t buf[256]; + char buf[256]; buf[0] = 0; - if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, + if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - buf, ARRAYSIZE(buf), nullptr)) - { - return strprintf("%s (%d)", std::wstring_convert,wchar_t>().to_bytes(buf), err); - } - else - { + buf, ARRAYSIZE(buf), nullptr)) { + return strprintf("%s (%d)", buf, err); + } else { return strprintf("Unknown error (%d)", err); } }