mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-19 03:41:34 +00:00
Set console codepage to utf-8 (on Windows), and restore old one on exit
Avoid mojibake.
This commit is contained in:
@@ -65,6 +65,20 @@ template <typename T> struct TypeIs64BitInteger { enum {value = false}; };
|
||||
template <> struct TypeIs64BitInteger<u64> { enum {value = true}; };
|
||||
template <> struct TypeIs64BitInteger<i64> { enum {value = true}; };
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
uint32_t old_console_codepage = 0;
|
||||
void set_utf8_codepage() {
|
||||
old_console_codepage = GetConsoleOutputCP();
|
||||
}
|
||||
|
||||
void restore_old_codepage() {
|
||||
// Nothing we can do if this fails, so we're not asserting or anything.
|
||||
SetConsoleOutputCP(old_console_codepage);
|
||||
}
|
||||
#else
|
||||
void set_utf8_codepage() {}
|
||||
void restore_old_codepage() {}
|
||||
#endif
|
||||
|
||||
|
||||
#include "unicode.cpp"
|
||||
|
||||
Reference in New Issue
Block a user