aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorChun Kuan Lee <ken2812221@gmail.com>2018-08-06 01:32:11 +0000
committerChun Kuan Lee <ken2812221@gmail.com>2018-09-11 21:09:46 +0800
commitd38bf9105d33147c899117a4c20ba7872733186f (patch)
tree4802258b9fb6fe2ea00ce762fbd10cb52c7d9899 /src/netbase.cpp
parent362518791ade834d7f1f25b679ba236dcf5c3ad0 (diff)
Call unicode API on Windows
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 4b63757f3d..093fd0bdb7 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -17,6 +17,8 @@
#ifndef WIN32
#include <fcntl.h>
+#else
+#include <codecvt>
#endif
#if !defined(MSG_NOSIGNAL)
@@ -649,13 +651,13 @@ bool LookupSubNet(const char* pszName, CSubNet& ret)
#ifdef WIN32
std::string NetworkErrorString(int err)
{
- char buf[256];
+ wchar_t buf[256];
buf[0] = 0;
- if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
+ if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- buf, sizeof(buf), nullptr))
+ buf, ARRAYSIZE(buf), nullptr))
{
- return strprintf("%s (%d)", buf, err);
+ return strprintf("%s (%d)", std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().to_bytes(buf), err);
}
else
{