简体   繁体   English

删除一部分Hexa Message 以获得好消息

[英]Remove a part of Hexa Message in order to have a good message

I tried to convert a String of Hex chars to a String using this method:我尝试使用此方法将十六进制字符字符串转换为字符串:

public String HexToString(String inputString){
    StringBuilder output = new StringBuilder();
    for (int i = 0; i < inputString.length(); i+=2) {
        String str = inputString.substring(i, i+2);
        output.append((char)Integer.parseInt(str, 16));
    }
    return output.toString();
}

Input is:输入是:

"4d442020000000020000000000000008ffffffff000000000000022200‌​0001b54d514852463220‌​20000000000000000141‌​4d5120434d504c4c3333‌​2020202020d75db05811‌​51d02000000000000000‌​00000000000000000000‌​00000000000000000000‌​00202020202020202020‌​20202020202020202020‌​20202020202020202020‌​20202020202020202020‌​20202020202020202043‌​4d504c4c333320202020‌​20202020202020202020‌​20000000000000000000‌​00000000020202020202‌​02020202020202020202‌​02020202020202020202‌​02020202020200000001‌​c7765626c6f6...." “4d442020000000020000000000000008ffffffff000000000000022200 0001b54d514852463220 20000000000000000141 4d5120434d504c4c3333 2020202020d75db05811 51d02000000000000000 00000000000000000000 00000000000000000000 00202020202020202020 20202020202020202020 20202020202020202020 20202020202020202020 20202020202020202043 4d504c4c333320202020 20202020202020202020 20000000000000000000 00000000020202020202 02020202020202020202 02020202020202020202 02020202020200000001 c7765626c6f6 ......”

This method works, but the problem that my message contains strange chars.此方法有效,但我的消息包含奇怪字符的问题。 After converting I received in the header this characters: "µMQHRF2"转换后,我在标题中收到此字符:“µMQHRF2”

The question is how could i delete this header ?问题是我怎么能删除这个标题? Should i do it when the message is on Hexa or after converting ?当消息在 Hexa 上或转换后我应该这样做吗? and how can i delete this characters from my string ?以及如何从我的字符串中删除这些字符?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM