/** * Will split up the hexString into sequences of 4 bytes with a memory page offset in front * * @param string * @return */ public static String pageView(String hexString) { StringBuilder pageView = new StringBuilder(); Formatter offsetFormat = new Formatter(pageView); if (hexString.length() % 8 != 0) { hexString += addPadding(hexString.length() % 8); } int pages = hexString.length() / 8; for (int page = 0; page < pages; page++) { String pageContent = hexString.substring(page * 8, page * 8 + 8); String byte0 = pageContent.substring(0, 2); String byte1 = pageContent.substring(2, 4); String byte2 = pageContent.substring(4, 6); String byte3 = pageContent.substring(6, 8); offsetFormat.format( "Page %04X : %2s:%2s:%2s:%2s %s\n", page, byte0, byte1, byte2, byte3, utf8(HexFormatter.fromHexString(pageContent.replaceAll("-", "0")))); } return pageView.toString(); }
public static String convertToUnicodeString(String hexString) { return utf8(HexFormatter.fromHexString(hexString)); // StringBuffer output = new StringBuffer(); // String subStr = null; // for (int i = 0; i < hexString.length(); i = i + 2) { // subStr = hexString.substring(i, i + 2); // char c = (char) Integer.parseInt(subStr, 16); // output.append(c); // } // return output.toString(); }
public static String convertByteToUnicodeString(byte[] b) { return convertToUnicodeString(HexFormatter.toHexString(b)); }