Skip to content

Commit

Permalink
utils: run commands using utf-8 string on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ken2812221 committed Aug 26, 2018
1 parent 427253c commit 23db954
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <codecvt>

#include <io.h> /* for _commit */
#include <shlobj.h>
Expand Down Expand Up @@ -1135,7 +1136,11 @@ fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
void runCommand(const std::string& strCommand)
{
if (strCommand.empty()) return;
#ifndef WIN32
int nErr = ::system(strCommand.c_str());
#else
int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().from_bytes(strCommand).c_str());
#endif
if (nErr)
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
}
Expand Down

0 comments on commit 23db954

Please sign in to comment.