mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-24 15:00:55 -04:00
Make console UTF-8 & VT sequences work reliably on Windows
This commit is contained in:
@@ -29,6 +29,7 @@ elseif (MSVC)
|
||||
add_compile_options(/Zc:strictStrings-)
|
||||
add_compile_options(/MP)
|
||||
add_compile_options(/W0)
|
||||
add_compile_options(/utf-8)
|
||||
endif ()
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error -Wno-c++11-narrowing")
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
#if _WIN32
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
int game_main(int argc, char* argv[]);
|
||||
|
||||
void WindowsSetupConsole();
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
WindowsSetupConsole();
|
||||
return game_main(argc, argv);
|
||||
}
|
||||
|
||||
void WindowsSetupConsole() {
|
||||
#if _WIN32
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
|
||||
auto stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD consoleMode;
|
||||
GetConsoleMode(stdout, &consoleMode);
|
||||
SetConsoleMode(stdout, consoleMode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user