From 89581a69b4021c8d01d5a6298a473d55c9763d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 26 Jul 2022 14:23:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/event/event_tcp_utils.go | 14 ++++++-------- business/jxstore/event/print_test.go | 10 ++++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/business/jxstore/event/event_tcp_utils.go b/business/jxstore/event/event_tcp_utils.go index 7846bd193..c3bdb2243 100644 --- a/business/jxstore/event/event_tcp_utils.go +++ b/business/jxstore/event/event_tcp_utils.go @@ -504,22 +504,20 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) { int16Sound := strconv.FormatInt(intSound, 16) voice += int16Sound } - voiceDataGBK, _ := jxutils.Utf8ToGbk([]byte(replaceContentOther(voice))) + voiceDataGBK, _ := jxutils.Utf8ToGbk([]byte(voice)) voiceData := hex.EncodeToString(voiceDataGBK) - globals.SugarLogger.Debug("voice============", voiceData) + //[8]sounda14 ->5b385d736f756e64613134 realSound := hexPrefixStr + voiceData allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2) if len(allLen) < 2 { allLen = "0" + allLen } - globals.SugarLogger.Debug("realSound============", realSound) - globals.SugarLogger.Debug("allLen============", allLen) - soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2)) - globals.SugarLogger.Debug("result1============", result) - result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr) - globals.SugarLogger.Debug("result2============", result) + //soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2)) + //result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr) + result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+hexPrefixStr) + result = strings.ReplaceAll(result, byteSignSoundE, "") //} } } diff --git a/business/jxstore/event/print_test.go b/business/jxstore/event/print_test.go index 424f5c709..9c35f1f55 100644 --- a/business/jxstore/event/print_test.go +++ b/business/jxstore/event/print_test.go @@ -3,8 +3,8 @@ package event import ( "encoding/hex" "fmt" + "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" - "strconv" "testing" ) @@ -34,5 +34,11 @@ func TestDC(t *testing.T) { // 十进制字符串转十六进制 func Test10Two16(t *testing.T) { - fmt.Println(strconv.FormatInt(11, 16)) // 2 to 10 + //fmt.Println(strconv.FormatInt(11, 16)) // 2 to 10 + //for _, v := range strings.Split("324c", "d") { + // fmt.Println(v) + //} + hexPrefix, _ := jxutils.Utf8ToGbk([]byte("[8]sounda14")) + hexPrefixStr := hex.EncodeToString(hexPrefix) + fmt.Println(hexPrefixStr) }