gitee.com/quant1x/gox@v1.21.2/text/runewidth/runewidth_windows.go (about)

     1  //go:build windows && !appengine
     2  // +build windows,!appengine
     3  
     4  package runewidth
     5  
     6  import (
     7  	"syscall"
     8  )
     9  
    10  var (
    11  	kernel32               = syscall.NewLazyDLL("kernel32")
    12  	procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP")
    13  )
    14  
    15  // IsEastAsian return true if the current locale is CJK
    16  func 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  }