I noticed in std.os.windows.kernel32 there are functions to get/set the output codepage, but not the input codepage.
I had to add this to make my program work:
pub const GetConsoleOutputCP = windows.kernel32.GetConsoleOutputCP;
pub const SetConsoleOutputCP = windows.kernel32.SetConsoleOutputCP;
pub extern "kernel32" fn GetConsoleCP() callconv(.winapi) windows.UINT;
pub extern "kernel32" fn SetConsoleCP(
wCodePageID: windows.UINT,
) callconv(.winapi) windows.BOOL;
const std = @import("std");
const windows = std.os.windows;
and I call them like this
// ensure console input/output is UTF-8
const utf8_codepage: c_uint = 65001;
if (winApi.SetConsoleOutputCP(utf8_codepage) == 0) return winApi.lastError();
if (winApi.SetConsoleCP(utf8_codepage) == 0) return winApi.lastError();
Or am I supposed to do it in a different way?