win32: for Unicode cmdline args, switch from cmd.exe to powershell.exe
Previously, to pass a subprocess cmdline args with Unicode characters,
we'd write the command line to a batch file and run it with cmd.exe. The
problem was that the batch file used chcp to get cmd.exe to be able to
read UTF-8 from the batch file, but this had the side-effect of changing
the codepage of the user's console window.
Instead of saving & restoring the codepage (which would always have the
risk of somehow leaving the console in the wrong codepage if a Ctrl-C
handler somehow wasn't called, or if Task Manager was used manually,
etc.), we use Windows PowerShell as the helper instead of cmd.exe.
PowerShell is installed on every version of Windows since Windows 7 and
is a separate free download for Windows XP and Windows Vista, but
realistically Windows XP is no longer supported by Microsoft and
probably no one chooses to run Windows Vista over Windows 7. Plus, this
change only uses PowerShell if Unicode args are passed.
Switching to PowerShell allows us to get rid of the temp file, context
manager, and messy __del__ that caused a variety of problems in the
past.
Change-Id: Ia3df533f7747f7b9b28a093f8ca24117371e5e59
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
1 file changed