@@ -210,6 +210,14 @@ extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn;
210
210
211
211
////////////////////////////////////////////////////////////////////////////////
212
212
213
+ /// Contains any logic that should be run on exe startup to bully Windows
214
+ /// into being a sane environment
215
+ inline fn setupWindows () void {
216
+ if (std .options .windows_force_utf8_codepage ) {
217
+ _ = std .os .windows .kernel32 .SetConsoleOutputCP (65001 ); // use UTF-8 codepage
218
+ }
219
+ }
220
+
213
221
fn _DllMainCRTStartup (
214
222
hinstDLL : std.os.windows.HINSTANCE ,
215
223
fdwReason : std.os.windows.DWORD ,
@@ -382,6 +390,7 @@ fn WinStartup() callconv(std.os.windows.WINAPI) noreturn {
382
390
_ = @import ("start_windows_tls.zig" );
383
391
}
384
392
393
+ setupWindows ();
385
394
std .debug .maybeEnableSegfaultHandler ();
386
395
387
396
std .os .windows .kernel32 .ExitProcess (initEventLoopAndCallMain ());
@@ -393,6 +402,7 @@ fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn {
393
402
_ = @import ("start_windows_tls.zig" );
394
403
}
395
404
405
+ setupWindows ();
396
406
std .debug .maybeEnableSegfaultHandler ();
397
407
398
408
const result : std.os.windows.INT = initEventLoopAndCallWinMain ();
@@ -495,6 +505,9 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
495
505
std .os .argv = argv [0.. argc ];
496
506
std .os .environ = envp ;
497
507
508
+ if (builtin .os .tag == .windows ) {
509
+ setupWindows ();
510
+ }
498
511
std .debug .maybeEnableSegfaultHandler ();
499
512
500
513
return initEventLoopAndCallMain ();
0 commit comments