From 76f709c2c382a4b443d6e6de5096f6a5d15e108e Mon Sep 17 00:00:00 2001 From: Allison Pierson Date: Tue, 3 Oct 2023 17:12:06 -0500 Subject: [PATCH] `win32`: Set console codepage to UTF-8 (#2726) --- internal/cli/cli_windows.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 internal/cli/cli_windows.go diff --git a/internal/cli/cli_windows.go b/internal/cli/cli_windows.go new file mode 100644 index 0000000000..1c8cf1fd53 --- /dev/null +++ b/internal/cli/cli_windows.go @@ -0,0 +1,12 @@ +package cli + +import "golang.org/x/sys/windows" + +func init() { + + kernel32 := windows.NewLazySystemDLL("kernel32.dll") + setConsoleCP := kernel32.NewProc("SetConsoleCP") + // Set codepage to UTF-8 + // https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers#:~:text=Unicode%20(UTF%2D7)-,65001,-utf%2D8 + setConsoleCP.Call(uintptr(65001)) +}