runewidth_windows.go 360 B

123456789101112131415161718192021222324
  1. package runewidth
  2. import (
  3. "syscall"
  4. )
  5. var (
  6. kernel32 = syscall.NewLazyDLL("kernel32")
  7. procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP")
  8. )
  9. func IsEastAsian() bool {
  10. r1, _, _ := procGetConsoleOutputCP.Call()
  11. if r1 == 0 {
  12. return false
  13. }
  14. switch int(r1) {
  15. case 932, 51932, 936, 949, 950:
  16. return true
  17. }
  18. return false
  19. }