MCPcopy Create free account
hub / github.com/capstone-engine/capstone / hexString2Byte

Method hexString2Byte

bindings/java/TestMips.java:11–20  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

9public class TestMips {
10
11 static byte[] hexString2Byte(String s) {
12 // from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
13 int len = s.length();
14 byte[] data = new byte[len / 2];
15 for (int i = 0; i < len; i += 2) {
16 data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
17 + Character.digit(s.charAt(i+1), 16));
18 }
19 return data;
20 }
21
22 static final String MIPS_CODE = "0C100097000000002402000c8fa2000034213456";
23 static final String MIPS_CODE2 = "56342134c2170100";

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected