diff --git a/controllers/api_controller.go b/controllers/api_controller.go index f3d4fefe1..bdcdffad9 100644 --- a/controllers/api_controller.go +++ b/controllers/api_controller.go @@ -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) {