This commit is contained in:
suyl
2021-07-09 18:18:07 +08:00
parent 4f4414d4f3
commit b270f5e452

View File

@@ -470,8 +470,13 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
//fd 固定
//001a (声音数据长度高八位低八位)
//0101 固定
soundPerfix := "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound + ","
hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPerfix))
soundPrefix := ""
if printer.Sound != "" {
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound + ","
} else {
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
}
hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
hexPrefixStr := hex.EncodeToString(hexPrefix)
realSound := hexPrefixStr + sound
allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)