From dd98e877d439c2e7a2d3a3c6d4c2a1d33f5ab177 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 14 Oct 2017 21:45:07 -0700 Subject: [PATCH] Windows: Fix over/under write for multibyte chars. --- Common/ConsoleListener.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index d899aaf1fd..49d9ce8feb 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -136,6 +136,7 @@ void ConsoleListener::Open() // Set the console window title SetConsoleTitle(title_.c_str()); SetConsoleCP(CP_UTF8); + SetConsoleOutputCP(CP_UTF8); // Set letter space LetterSpace(openWidth_, LOG_MAX_DISPLAY_LINES); @@ -503,7 +504,7 @@ void ConsoleListener::WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Tex SetConsoleTextAttribute(hConsole, Color); int wlen = MultiByteToWideChar(CP_UTF8, 0, Text, (int)Len, NULL, NULL); MultiByteToWideChar(CP_UTF8, 0, Text, (int)Len, tempBuf, wlen); - WriteConsole(hConsole, tempBuf, (DWORD)Len, &cCharsWritten, NULL); + WriteConsole(hConsole, tempBuf, (DWORD)wlen, &cCharsWritten, NULL); } #endif