Skip to content

Commit dbe770d

Browse files
committed
Switch to ANSI Windows API in Win32ErrorString() function
1 parent 06d0be4 commit dbe770d

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/util/syserror.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
#if defined(WIN32)
1414
#include <windows.h>
15-
#include <locale>
16-
#include <codecvt>
1715
#endif
1816

1917
std::string SysErrorString(int err)
@@ -41,16 +39,13 @@ std::string SysErrorString(int err)
4139
#if defined(WIN32)
4240
std::string Win32ErrorString(int err)
4341
{
44-
wchar_t buf[256];
42+
char buf[256];
4543
buf[0] = 0;
46-
if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
44+
if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
4745
nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
48-
buf, ARRAYSIZE(buf), nullptr))
49-
{
50-
return strprintf("%s (%d)", std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().to_bytes(buf), err);
51-
}
52-
else
53-
{
46+
buf, ARRAYSIZE(buf), nullptr)) {
47+
return strprintf("%s (%d)", buf, err);
48+
} else {
5449
return strprintf("Unknown error (%d)", err);
5550
}
5651
}

0 commit comments

Comments
 (0)