This commit is contained in:
suyl
2021-07-14 09:38:31 +08:00
parent d083ca165e
commit 7284949cd7

View File

@@ -376,12 +376,37 @@ func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (data, errCo
} else {
if byteData, err := json.Marshal(printMsg); err == nil {
data = string(byteData)
data = unicode2utf8(data)
} else {
return "", model.ErrCodeGeneralFailed, err
}
}
return data, errCode, err
}
func unicode2utf8(source string) string {
var res = []string{""}
sUnicode := strings.Split(source, "\\u")
var context = ""
for _, v := range sUnicode {
var additional = ""
if len(v) < 1 {
continue
}
if len(v) > 4 {
rs := []rune(v)
v = string(rs[:4])
additional = string(rs[4:])
}
temp, err := strconv.ParseInt(v, 16, 32)
if err != nil {
context += v
}
context += fmt.Sprintf("%c", temp)
context += additional
}
res = append(res, context)
return strings.Join(res, "")
}
//查询打印机状态
func (c *ApiController) GetPrinterStatus(dataMap map[string]interface{}) (data, errCode string, err error) {