From d38bf9105d33147c899117a4c20ba7872733186f Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Mon, 6 Aug 2018 01:32:11 +0000 Subject: Call unicode API on Windows --- src/netbase.cpp | 10 ++++++---- src/util.cpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') 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 +#else +#include #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,wchar_t>().to_bytes(buf), err); } else { diff --git a/src/util.cpp b/src/util.cpp index 84a4adcfd4..a844b4a248 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -997,7 +997,7 @@ void CreatePidFile(const fs::path &path, pid_t pid) bool RenameOver(fs::path src, fs::path dest) { #ifdef WIN32 - return MoveFileExA(src.string().c_str(), dest.string().c_str(), + return MoveFileExW(src.wstring().c_str(), dest.wstring().c_str(), MOVEFILE_REPLACE_EXISTING) != 0; #else int rc = std::rename(src.string().c_str(), dest.string().c_str()); -- cgit v1.2.3