From e1097ab39decf853abbb6a934c47afa841445237 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 10 May 2017 02:21:03 +0200 Subject: Use UTF8 encoding for output on windows console. This avoids the misery and frustration of converting to the overly limited ANSI codepages and does not seem to cause any issues so far. (bzr r15682) --- src/winconsole.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/winconsole.cpp') diff --git a/src/winconsole.cpp b/src/winconsole.cpp index 085fb441c..f91b19c5c 100644 --- a/src/winconsole.cpp +++ b/src/winconsole.cpp @@ -100,6 +100,11 @@ int main() // it guarantees perfect behavior w.r.t. quoting WCHAR *cmd = GetCommandLineW(); + // temporarily switch console encoding to UTF8 while the spwaned process runs + // as everything else is a mess and it seems to work just fine + const unsigned int initial_cp = GetConsoleOutputCP(); + SetConsoleOutputCP(CP_UTF8); + // set up the pipes and handles stdin.echo_read = GetStdHandle(STD_INPUT_HANDLE); stdout.echo_write = GetStdHandle(STD_OUTPUT_HANDLE); @@ -148,6 +153,9 @@ int main() // wait until the standard output thread terminates WaitForSingleObject(stdout_thread, INFINITE); + // switch back to initial console encoding + SetConsoleOutputCP(initial_cp); + return 0; } -- cgit v1.2.3