From 5dc35d3b59b8d76a7438036166c786a1b1675b3f Mon Sep 17 00:00:00 2001 From: asctime Date: Sat, 17 Jun 2023 02:07:18 +1000 Subject: [PATCH] Disable _O_WTEXT when using main in MinGW --- examples/common.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/common.cpp b/examples/common.cpp index b47f06273..792595396 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -594,7 +594,11 @@ void console_init(console_state & con_st) { HANDLE hConIn = GetStdHandle(STD_INPUT_HANDLE); if (hConIn != INVALID_HANDLE_VALUE && GetConsoleMode(hConIn, &dwMode)) { // Set console input codepage to UTF16 +#ifdef __MINGW32__ /* UTF16 requires wmain in MinGW */ + _setmode(_fileno(stdin), _O_TEXT); +#else _setmode(_fileno(stdin), _O_WTEXT); +#endif // Turn off ICANON (ENABLE_LINE_INPUT) and ECHO (ENABLE_ECHO_INPUT) dwMode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);