@@ -228,7 +228,7 @@ namespace core
228228
229229 // ////////////////////////////////////////////////////////////////////////
230230 // Deprecated, CANNOT hide console window
231- static int ShellExecuteByPipe_Old (std::tstring strCmdLine, std::tstring & strOutput)
231+ static int ShellExecuteByPipe_Old (std::tstring strCmdLine, std::string & strOutput)
232232 {
233233 FILE* pPipe = NULL ;
234234 try
@@ -240,7 +240,7 @@ namespace core
240240 const size_t tBuffSize = 64 ;
241241 char szBuf[tBuffSize];
242242 while (::fgets (szBuf, tBuffSize, pPipe))
243- strOutput += TCSFromMBS ( szBuf) ;
243+ strOutput += szBuf;
244244 }
245245 catch (std::exception& e)
246246 {
@@ -273,7 +273,7 @@ namespace core
273273 }
274274
275275 // ////////////////////////////////////////////////////////////////////////
276- static ECODE ShellExecuteByPipe_New (std::tstring strCmdLine, std::tstring & strOutput, DWORD& dwExitCode)
276+ static ECODE ShellExecuteByPipeWorker (std::tstring strCmdLine, std::string & strOutput, DWORD& dwExitCode)
277277 {
278278 PROCESS_INFORMATION stProcessInfo = { 0 , };
279279 HANDLE hStdOutPair[2 ] = { 0 , };
@@ -305,11 +305,9 @@ namespace core
305305 if (!::CreateProcess (NULL , (LPTSTR)strCmdLine.c_str (), NULL , NULL , TRUE , 0 , NULL , NULL , &stStartupInfo, &stProcessInfo))
306306 throw exception_format (TEXT (" Failed to CreateProcess(%s)" ), strCmdLine.c_str ());
307307
308- std::string strTempOutput;
309308 while (WAIT_TIMEOUT == ::WaitForSingleObject (stProcessInfo.hProcess , 100 ))
310- ReadContextFromPipe (hStdOutPair[0 ], strTempOutput);
311- ReadContextFromPipe (hStdOutPair[0 ], strTempOutput);
312- strOutput = TCSFromUTF8 (strTempOutput);
309+ ReadContextFromPipe (hStdOutPair[0 ], strOutput);
310+ ReadContextFromPipe (hStdOutPair[0 ], strOutput);
313311
314312 if (!GetExitCodeProcess (stProcessInfo.hProcess , &dwExitCode))
315313 Log_Warn (TEXT (" GetExitCodeProcess failure." ));
@@ -337,10 +335,10 @@ namespace core
337335 }
338336
339337 // ////////////////////////////////////////////////////////////////////////
340- int ShellExecuteByPipe (std::tstring strCmdLine, std::tstring & strOutput)
338+ int ShellExecuteByPipe (std::tstring strCmdLine, std::string & strOutput)
341339 {
342340 DWORD dwExitCode = 0 ;
343- ECODE nRet = ShellExecuteByPipe_New (strCmdLine, strOutput, dwExitCode);
341+ ECODE nRet = ShellExecuteByPipeWorker (strCmdLine, strOutput, dwExitCode);
344342 if (EC_SUCCESS != nRet)
345343 return ShellExecuteByPipe_Old (strCmdLine, strOutput);
346344
0 commit comments