Set console codepage to utf-8 (on Windows), and restore old one on exit

Avoid mojibake.
This commit is contained in:
Jeroen van Rijn
2026-08-16 16:16:35 +02:00
parent e62ed261c5
commit 0b7b8ba4a2
3 changed files with 72 additions and 8 deletions

View File

@@ -3794,6 +3794,13 @@ int main(int arg_count, char const **arg_ptr) {
defer (timings_destroy(&global_timings));
MAIN_TIME_SECTION("initialization");
// NOTE(Jeroen): Set codepage to UTF-8 (Windows only) and restore on exit.
// Keep in mind this is for the compiler's own output only.
// Like error messages on lines containing unicode.
// Child processes will inherit the default codepage,
// and so must do their own codepage management if they want.
set_utf8_codepage();
defer (restore_old_codepage());
init_string_interner();
init_global_error_collector();