Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String convertToHexValue(String lit) {
- StringBuilder s = new StringBuilder();
- if (lit.startsWith("=C")) {
- lit = lit.replace("=C'", "").replace("'", "");
- for (char ch : lit.toCharArray()) {
- s.append(String.format("%x", (int) ch));
- }
- } else if (lit.startsWith("=X")) {
- lit = lit.replace("=X'", "").replace("'", "");
- for (int i = 0; i < lit.length(); i += 2) {
- String str = lit.substring(i, i + 2);
- s.append((char) Integer.parseInt(str, 16));
- }
- }
- String hexValueOfLiteral = s.toString().toUpperCase();
- return hexValueOfLiteral;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement