MCPcopy Create free account
hub / github.com/Monibuca/engine / IsTerminalSupportChinese

Function IsTerminalSupportChinese

lang/lang.go:45–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43}
44
45func IsTerminalSupportChinese() bool {
46 // 获取终端的环境变量
47 env := os.Environ()
48
49 // 查找 LANG 环境变量
50 isSupportUTF8 := false
51 for _, v := range env {
52 if strings.Index(v, "LANG") != -1 && strings.Index(v, "UTF-8") != -1 {
53 isSupportUTF8 = true
54 }
55 }
56 if isSupportUTF8 {
57 // 在终端中打印中文字符
58 cmd := exec.Command("echo", "你好!")
59 _, err := cmd.CombinedOutput()
60 if err == nil {
61 return true
62 }
63 return false
64 }
65 return false
66}

Callers 1

GetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected