Skip to content

Commit d38bf91

Browse files
committed
Call unicode API on Windows
1 parent 3625187 commit d38bf91

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/netbase.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#ifndef WIN32
1919
#include <fcntl.h>
20+
#else
21+
#include <codecvt>
2022
#endif
2123

2224
#if !defined(MSG_NOSIGNAL)
@@ -649,13 +651,13 @@ bool LookupSubNet(const char* pszName, CSubNet& ret)
649651
#ifdef WIN32
650652
std::string NetworkErrorString(int err)
651653
{
652-
char buf[256];
654+
wchar_t buf[256];
653655
buf[0] = 0;
654-
if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
656+
if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
655657
nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
656-
buf, sizeof(buf), nullptr))
658+
buf, ARRAYSIZE(buf), nullptr))
657659
{
658-
return strprintf("%s (%d)", buf, err);
660+
return strprintf("%s (%d)", std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().to_bytes(buf), err);
659661
}
660662
else
661663
{

src/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ void CreatePidFile(const fs::path &path, pid_t pid)
997997
bool RenameOver(fs::path src, fs::path dest)
998998
{
999999
#ifdef WIN32
1000-
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
1000+
return MoveFileExW(src.wstring().c_str(), dest.wstring().c_str(),
10011001
MOVEFILE_REPLACE_EXISTING) != 0;
10021002
#else
10031003
int rc = std::rename(src.string().c_str(), dest.string().c_str());

0 commit comments

Comments
 (0)