unicode
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user