Commit bee414dee56092d1804203209ad589715670839c
1 parent
92de8c2b
海亮定制
Showing
1 changed file
with
19 additions
and
4 deletions
海亮定制.md
| @@ -458,7 +458,7 @@ ${clinetId} clinetId 是基站编号,为替换字符串。 | @@ -458,7 +458,7 @@ ${clinetId} clinetId 是基站编号,为替换字符串。 | ||
| 458 | "m": { | 458 | "m": { | 
| 459 | "qt": 0, | 459 | "qt": 0, | 
| 460 | "on": 4, | 460 | "on": 4, | 
| 461 | - "content": "hex:c7ebbbd8b4f0cfc2c3e633b5c0cad4cce2" | 461 | + "content": "hex:d5c5c8fd" | 
| 462 | } | 462 | } | 
| 463 | } | 463 | } | 
| 464 | ``` | 464 | ``` | 
| @@ -472,7 +472,8 @@ ${clinetId} clinetId 是基站编号,为替换字符串。 | @@ -472,7 +472,8 @@ ${clinetId} clinetId 是基站编号,为替换字符串。 | ||
| 472 | | content = 1 |题目主干内容,hex: 为内容的GBK编码的hex内容 | | 472 | | content = 1 |题目主干内容,hex: 为内容的GBK编码的hex内容 | | 
| 473 | 473 | ||
| 474 | ```java | 474 | ```java | 
| 475 | -String content = "hex:" + bytesToHexString(title.getBytes("GBK")) | 475 | + | 
| 476 | +System.out.println(new String(hex2Bytes(bytesToHexString("李四".getBytes("GBK"))),"GBK")); | ||
| 476 | 477 | ||
| 477 | public static String bytesToHexString(byte[] src) { | 478 | public static String bytesToHexString(byte[] src) { | 
| 478 | StringBuilder stringBuilder = new StringBuilder(""); | 479 | StringBuilder stringBuilder = new StringBuilder(""); | 
| @@ -490,6 +491,17 @@ public static String bytesToHexString(byte[] src) { | @@ -490,6 +491,17 @@ public static String bytesToHexString(byte[] src) { | ||
| 490 | } | 491 | } | 
| 491 | return stringBuilder.toString(); | 492 | return stringBuilder.toString(); | 
| 492 | } | 493 | } | 
| 494 | + | ||
| 495 | + public static byte[] hex2Bytes(String hex){ | ||
| 496 | + if(hex.length() % 2 == 0){ | ||
| 497 | + byte[] ret = new byte[hex.length() / 2]; | ||
| 498 | + for(int i = 0 ; i< hex.length() / 2 ; i++){ | ||
| 499 | + ret[i] = (byte)Integer.parseInt(hex.substring(2*i,2*i+2),16); | ||
| 500 | + } | ||
| 501 | + return ret; | ||
| 502 | + } | ||
| 503 | + return null; | ||
| 504 | +} | ||
| 493 | ``` | 505 | ``` | 
| 494 | 506 | ||
| 495 | #### 接收答题数据 | 507 | #### 接收答题数据 | 
| @@ -796,10 +808,10 @@ public static String bytesToHexString(byte[] src) { | @@ -796,10 +808,10 @@ public static String bytesToHexString(byte[] src) { | ||
| 796 | "cmd": 1, | 808 | "cmd": 1, | 
| 797 | "m": [{ | 809 | "m": [{ | 
| 798 | "sn": "2126833671", | 810 | "sn": "2126833671", | 
| 799 | - "text": "hex:5f204e09" | 811 | + "text": "hex:d5c5c8fd" | 
| 800 | },{ | 812 | },{ | 
| 801 | "sn": "2126833672", | 813 | "sn": "2126833672", | 
| 802 | - "text": "hex:674e56db" | 814 | + "text": "hex:c0eecbc4" | 
| 803 | }] | 815 | }] | 
| 804 | } | 816 | } | 
| 805 | ``` | 817 | ``` | 
| @@ -812,6 +824,9 @@ public static String bytesToHexString(byte[] src) { | @@ -812,6 +824,9 @@ public static String bytesToHexString(byte[] src) { | ||
| 812 | 824 | ||
| 813 | 825 | ||
| 814 | ```java | 826 | ```java | 
| 827 | + | ||
| 828 | + System.out.println(bytesToHexString("李四".getBytes("GBK"))); | ||
| 829 | + | ||
| 815 | public static String bytesToHexString(byte[] src) { | 830 | public static String bytesToHexString(byte[] src) { | 
| 816 | StringBuilder stringBuilder = new StringBuilder(""); | 831 | StringBuilder stringBuilder = new StringBuilder(""); | 
| 817 | if (src == null || src.length <= 0) { | 832 | if (src == null || src.length <= 0) { | 
