From ab1f92fc93b71c46d3eb1e2176745708789a1400 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" <destructionator@gmail.com> Date: Wed, 2 Jan 2019 21:35:25 -0500 Subject: [PATCH] set utf8 mode on windows too --- terminal.d | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/terminal.d b/terminal.d index 40bf7da..7114ef7 100644 --- a/terminal.d +++ b/terminal.d @@ -804,11 +804,19 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683193%28v=vs.85%29.as defaultForegroundColor = cast(Color) (originalSbi.wAttributes & 0x0f); defaultBackgroundColor = cast(Color) ((originalSbi.wAttributes >> 4) & 0x0f); + + oldCp = GetConsoleOutputCP(); + SetConsoleOutputCP(65001); // UTF-8 + + oldCpIn = GetConsoleCP(); + SetConsoleCP(65001); // UTF-8 } version(Windows) { private Color defaultBackgroundColor = Color.black; private Color defaultForegroundColor = Color.white; + UINT oldCp; + UINT oldCpIn; } // only use this if you are sure you know what you want, since the terminal is a shared resource you generally really want to reset it to normal when you leave... @@ -843,6 +851,10 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683193%28v=vs.85%29.as if(lineGetter !is null) lineGetter.dispose(); + + SetConsoleOutputCP(oldCp); + SetConsoleCP(oldCpIn); + auto stdo = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleActiveScreenBuffer(stdo); if(hConsole !is stdo)