Merge #13886: utils: run commands using utf-8 string on Windows

23db9546c1 utils: run commands using utf-8 string on Windows (Chun Kuan Lee)

Pull request description:

  Use unicode string to call commans

Tree-SHA512: 72f84e7b56cd947ad05176f10b5ddd5610f4641ba5e93ffd67777dea8f9734ec06e6ed3a63f67ae5e766767122c0dd2c441d0bad5572bdb9fb78758f02531feb
This commit is contained in:
Wladimir J. van der Laan 2018-09-12 11:20:56 +02:00
commit 1c12cf6073
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
1 changed files with 5 additions and 0 deletions

View File

@ -58,6 +58,7 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <codecvt>
#include <io.h> /* for _commit */
#include <shlobj.h>
@ -1154,7 +1155,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);
}