提交 bbae0816 编写于 作者: Z zhaoke

* Add convert to utf8 .

上级 26ec51ca
......@@ -109,6 +109,7 @@ func RunFile(filePath, workspacePath string, conf commDomain.WorkspaceConf,
for {
line, err2 := reader1.ReadString('\n')
if line != "" {
line = stringUtils.Convert2Utf8IfNeeded(line)
if commConsts.ExecFrom == commConsts.FromClient {
websocketHelper.SendOutputMsg(line, "", iris.Map{"key": key}, wsMsg)
logUtils.ExecConsole(-1, line)
......@@ -157,6 +158,7 @@ ExitCurrCase:
if err2 != nil || io.EOF == err2 {
break
}
line = stringUtils.Convert2Utf8IfNeeded(line)
errOutputArr = append(errOutputArr, line)
}
}
......
package stringUtils
import (
"unicode/utf8"
"golang.org/x/text/encoding/simplifiedchinese"
)
func Convert2Utf8IfNeeded(data string) string {
if !utf8.Valid([]byte(data)) && IsGBK([]byte(data)) {
newLine, _ := simplifiedchinese.GBK.NewDecoder().Bytes([]byte(data))
data = string(newLine)
}
return data
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册