Merge #13888: Call unicode API on Windows
d38bf9105d
Call unicode API on Windows (Chun Kuan Lee)
Pull request description:
Call Unicode API on Windows
Tree-SHA512: 93c290ee79c9d911fdada8ba45e184fc4f14d3cb56f33f39223286213878b08e8c4dd296a80099c57797d3b8589870e6cff622b22e76123d7452659d49dd8309
This commit is contained in:
commit
37b836ad09
2 changed files with 7 additions and 5 deletions
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#else
|
||||||
|
#include <codecvt>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(MSG_NOSIGNAL)
|
#if !defined(MSG_NOSIGNAL)
|
||||||
|
@ -649,13 +651,13 @@ bool LookupSubNet(const char* pszName, CSubNet& ret)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
std::string NetworkErrorString(int err)
|
std::string NetworkErrorString(int err)
|
||||||
{
|
{
|
||||||
char buf[256];
|
wchar_t buf[256];
|
||||||
buf[0] = 0;
|
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),
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -998,7 +998,7 @@ void CreatePidFile(const fs::path &path, pid_t pid)
|
||||||
bool RenameOver(fs::path src, fs::path dest)
|
bool RenameOver(fs::path src, fs::path dest)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#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;
|
MOVEFILE_REPLACE_EXISTING) != 0;
|
||||||
#else
|
#else
|
||||||
int rc = std::rename(src.string().c_str(), dest.string().c_str());
|
int rc = std::rename(src.string().c_str(), dest.string().c_str());
|
||||||
|
|
Loading…
Reference in a new issue