diff --git a/base/runtime/core.odin b/base/runtime/core.odin index 41d620bdd..0453583c0 100644 --- a/base/runtime/core.odin +++ b/base/runtime/core.odin @@ -945,5 +945,25 @@ default_assertion_contextless_failure_proc :: proc "contextless" (prefix, messag print_byte('\n') } } + when ODIN_CODEPAGE_MAGIC { + SetConsoleOutputCP(old_console_codepage) + } trap() } + +ODIN_CODEPAGE_MAGIC :: ODIN_OS == .Windows && #config(ODIN_CODEPAGE_MAGIC, !ODIN_BEDROCK) + +when ODIN_CODEPAGE_MAGIC { + @(private) + old_console_codepage: u32 + + @(private) + UTF_8 :: 65001 +} + +foreign import kernel32 "system:Kernel32.lib" +@(default_calling_convention="system") +foreign kernel32 { + GetConsoleOutputCP :: proc() -> u32 --- + SetConsoleOutputCP :: proc(codepage: u32) -> b32 --- +} \ No newline at end of file diff --git a/base/runtime/entry_windows.odin b/base/runtime/entry_windows.odin index 119d50b54..5e7753d6a 100644 --- a/base/runtime/entry_windows.odin +++ b/base/runtime/entry_windows.odin @@ -5,16 +5,6 @@ package runtime import "base:intrinsics" -ODIN_CODEPAGE_MAGIC :: #config(ODIN_CODEPAGE_MAGIC, !ODIN_BEDROCK) - -when ODIN_CODEPAGE_MAGIC { - @(private="file") - old_console_codepage: u32 - - @(private="file") - UTF_8 :: 65001 -} - when ODIN_BUILD_MODE == .Dynamic { @(link_name="DllMain", linkage="strong", require) DllMain :: proc "system" (hinstDLL: rawptr, fdwReason: u32, lpReserved: rawptr) -> b32 { @@ -90,11 +80,4 @@ when ODIN_BUILD_MODE == .Dynamic { return 0 } } -} - -foreign import kernel32 "system:Kernel32.lib" -@(default_calling_convention="system") -foreign kernel32 { - GetConsoleOutputCP :: proc() -> u32 --- - SetConsoleOutputCP :: proc(codepage: u32) -> b32 --- } \ No newline at end of file diff --git a/base/runtime/procs_windows_amd64.odin b/base/runtime/procs_windows_amd64.odin index 81d2cfb5d..cedbc2bd8 100644 --- a/base/runtime/procs_windows_amd64.odin +++ b/base/runtime/procs_windows_amd64.odin @@ -11,8 +11,9 @@ foreign kernel32 { windows_trap_array_bounds :: proc "contextless" () -> ! { EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C - - + when ODIN_CODEPAGE_MAGIC { + SetConsoleOutputCP(old_console_codepage) + } RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, 0, 0, nil) } diff --git a/base/runtime/procs_windows_i386.odin b/base/runtime/procs_windows_i386.odin index 99c314228..9dd97116d 100644 --- a/base/runtime/procs_windows_i386.odin +++ b/base/runtime/procs_windows_i386.odin @@ -15,7 +15,9 @@ windows_trap_array_bounds :: proc "contextless" () -> ! { foreign kernel32 { RaiseException :: proc "system" (dwExceptionCode, dwExceptionFlags, nNumberOfArguments: DWORD, lpArguments: ^ULONG_PTR) -> ! --- } - + when ODIN_CODEPAGE_MAGIC { + SetConsoleOutputCP(old_console_codepage) + } RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, 0, 0, nil) }