From 6dd463409b3f7f8e688b76a5ff53c1fa4df51690 Mon Sep 17 00:00:00 2001 From: Elvis Date: Sat, 3 Feb 2024 13:52:45 +0800 Subject: [PATCH] 海亮 --- 海亮定制.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/海亮定制.md b/海亮定制.md index cafda2c..c3f50e2 100644 --- a/海亮定制.md +++ b/海亮定制.md @@ -458,7 +458,7 @@ ${clinetId} clinetId 是基站编号,为替换字符串。 "m": { "qt": 0, "on": 4, - "content": "hex:c7ebbbd8b4f0cfc2c3e633b5c0cad4cce2" + "content": "hex:d5c5c8fd" } } ``` @@ -472,7 +472,8 @@ ${clinetId} clinetId 是基站编号,为替换字符串。 | content = 1 |题目主干内容,hex: 为内容的GBK编码的hex内容 | ```java -String content = "hex:" + bytesToHexString(title.getBytes("GBK")) + +System.out.println(new String(hex2Bytes(bytesToHexString("李四".getBytes("GBK"))),"GBK")); public static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(""); @@ -490,6 +491,17 @@ public static String bytesToHexString(byte[] src) { } return stringBuilder.toString(); } + + public static byte[] hex2Bytes(String hex){ + if(hex.length() % 2 == 0){ + byte[] ret = new byte[hex.length() / 2]; + for(int i = 0 ; i< hex.length() / 2 ; i++){ + ret[i] = (byte)Integer.parseInt(hex.substring(2*i,2*i+2),16); + } + return ret; + } + return null; +} ``` #### 接收答题数据 @@ -796,10 +808,10 @@ public static String bytesToHexString(byte[] src) { "cmd": 1, "m": [{ "sn": "2126833671", - "text": "hex:5f204e09" + "text": "hex:d5c5c8fd" },{ "sn": "2126833672", - "text": "hex:674e56db" + "text": "hex:c0eecbc4" }] } ``` @@ -812,6 +824,9 @@ public static String bytesToHexString(byte[] src) { ```java + + System.out.println(bytesToHexString("李四".getBytes("GBK"))); + public static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(""); if (src == null || src.length <= 0) { -- libgit2 0.21.4