runewidth_windows.go 479 B

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