Windows: Fix over/under write for multibyte chars.

This commit is contained in:
Unknown W. Brackets committed 2017-10-14 21:45:07 -07:00
1 parent ed602a3319
commit dd98e877d4
1 file changed
+2 -1
+2 -1
View File
@@ -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