runewidth_windows.go

 1//go:build windows && !appengine
 2// +build windows,!appengine
 3
 4package runewidth
 5
 6import (
 7	"syscall"
 8)
 9
10var (
11	kernel32               = syscall.NewLazyDLL("kernel32")
12	procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP")
13)
14
15// IsEastAsian return true if the current locale is CJK
16func IsEastAsian() bool {
17	r1, _, _ := procGetConsoleOutputCP.Call()
18	if r1 == 0 {
19		return false
20	}
21
22	switch int(r1) {
23	case 932, 51932, 936, 949, 950:
24		return true
25	}
26
27	return false
28}