Skip to content

Commit 5f713a7

Browse files
authored
Fixed UTF-8 console encoding setup for Windows OS (#2889)
Not only the input console encoding should be set to UTF-8, but also the output console encoding.
1 parent 0c0a8eb commit 5f713a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/cli/cli_windows.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ package cli
33
import "golang.org/x/sys/windows"
44

55
func init() {
6-
76
kernel32 := windows.NewLazySystemDLL("kernel32.dll")
7+
88
setConsoleCP := kernel32.NewProc("SetConsoleCP")
9-
// Set codepage to UTF-8
9+
// Set console input codepage to UTF-8
1010
// https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers#:~:text=Unicode%20(UTF%2D7)-,65001,-utf%2D8
1111
setConsoleCP.Call(uintptr(65001))
12+
13+
setConsoleOutputCP := kernel32.NewProc("SetConsoleOutputCP")
14+
// Set console ouput codepage to UTF-8
15+
setConsoleOutputCP.Call(uintptr(65001))
1216
}

0 commit comments

Comments
 (0)