[英]Vertical Hex to ASCII Java
Situation: 情况:
I have a GUI where i already convert a horizontal Hex into ASCII... But now i want to convert a vertical Hex to ASCII. 我有一个GUI,我已经将水平十六进制转换为ASCII ...但是现在我想将垂直十六进制转换为ASCII。
Does anyone have some ideas how i can solve this? 有谁知道我该如何解决这个问题?
I already splited it: 我已经拆分了:
vert.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fintext5.setText("");
String[] test = entertext3.getText().split("\\n");
for(int i = 0; i<test.length; i++){
System.out.prinln(test[i]);
}
}
});
Code for horizontal Hex: 水平十六进制代码:
button5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fintext5.setText("");
String readout = entertext3.getText().replace(" ", "").replace("\n", "");
StringBuilder output = new StringBuilder("");
for (int i = 0; i < readout.length(); i += 2)
{
String str = readout.substring(i, i + 2);
output.append((char) Integer.parseInt(str, 16));
}
fintext5.append(output.toString());
}
});
Example for vertical Hex(41 42 43 44 45 46): 垂直十六进制示例(41 42 43 44 45 46):
4 4 4
1 2 3
4 4 4
4 5 6
You're getting so lost, I'll just give you a working starting point: 您已经迷失了,我只是给您一个工作的出发点:
vert.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ausgabe5.setText("");
String[] test = eingabe3.getText().split("\\n");
StringBuilder output = new StringBuilder();
for (int i = 0; i < test.length; i += 2) {
for (int j = 0; j < test[i].length(); j++) {
String hex = "" + test[i].charAt(j) + test[i + 1].charAt(j);
output.append((char)Integer.parseInt(hex,16));
}
}
System.out.println(output.toString());
}
});
Please look it over and ask about anything you don't understand. 请仔细查看,询问任何您不了解的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.