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