Skip to content

Commit b371321

Browse files
committed
utils: run commands using utf-8 string on Windows
1 parent 19f3ee9 commit b371321

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#ifndef NOMINMAX
6666
#define NOMINMAX
6767
#endif
68+
#include <codecvt>
6869

6970
#include <io.h> /* for _commit */
7071
#include <shlobj.h>
@@ -747,7 +748,12 @@ double double_safe_multiplication(double fValue, double fmultiplicator)
747748

748749
void runCommand(std::string strCommand)
749750
{
751+
if (strCommand.empty()) return;
752+
#ifndef WIN32
750753
int nErr = ::system(strCommand.c_str());
754+
#else
755+
int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().from_bytes(strCommand).c_str());
756+
#endif
751757
if (nErr)
752758
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
753759
}

0 commit comments

Comments
 (0)