From 520f6c662534355c0a496f2323e50dd30b21be8a Mon Sep 17 00:00:00 2001 From: CPunch Date: Sat, 9 Mar 2024 16:23:41 -0600 Subject: [PATCH 1/2] linux: set console codepage to UTF8 --- source/terml.cpp | 1 + source/terml_private.h | 1 + 2 files changed, 2 insertions(+) diff --git a/source/terml.cpp b/source/terml.cpp index 5dffd2e..772476b 100644 --- a/source/terml.cpp +++ b/source/terml.cpp @@ -243,6 +243,7 @@ void terml::set_console_settings() { setvbuf(stdout, nullptr, _IOFBF, BUFSIZ * BUFSIZ); printf(ALT_BUF() HIDE_CURSOR()); + printf(SELECT_UTF8()); fflush(stdout); set_console_settings_impl(); } diff --git a/source/terml_private.h b/source/terml_private.h index 679ab0c..3e8fbc6 100644 --- a/source/terml_private.h +++ b/source/terml_private.h @@ -16,6 +16,7 @@ #define HIDE_CURSOR() CSI "?25l" #define SHOW_CURSOR() CSI "?25h" +#define SELECT_UTF8() CSI "%G" #define REPORT_CUSROR_POSITION() CSI "6n" #define CURSOR_POSITION_FORMAT() "%*1s[%u;%u" From 17b275b09827cbc95936c5700c8745c02a898783 Mon Sep 17 00:00:00 2001 From: CPunch Date: Sat, 9 Mar 2024 16:27:43 -0600 Subject: [PATCH 2/2] moved SELECT_UTF8() to the same line --- source/terml.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/terml.cpp b/source/terml.cpp index 772476b..ad420c3 100644 --- a/source/terml.cpp +++ b/source/terml.cpp @@ -242,8 +242,7 @@ void terml::setup_buffer() void terml::set_console_settings() { setvbuf(stdout, nullptr, _IOFBF, BUFSIZ * BUFSIZ); - printf(ALT_BUF() HIDE_CURSOR()); - printf(SELECT_UTF8()); + printf(ALT_BUF() HIDE_CURSOR() SELECT_UTF8()); fflush(stdout); set_console_settings_impl(); }