0

I want to convert a String value to hex and then back to it's ascii value. when I'm converting it to the hex value i'm doing it with the charset - cp424.

this is what i'm trying to do:

String str = "abcאבג";               
String hexString = Hex.encodeHexString(str.getBytes("cp424")); 
//some action         
String original_value = Hex.decodeHex(hexString.toCharArray()).toString();

My problem is beacuse i'm using cp424 when converting to hex I need when converting back to get it back to the defult charset. I tried this convertion in many ways but didn't get the correct value.

how can this be done? how can i get back the original value from the hex value??

Thank's In Advance.

user590586
  • 2,960
  • 16
  • 63
  • 96

1 Answers1

2

Create original_value using the String(byte[] bytes, String charsetName) constructor:

String original_value = new String(Hex.decodeHex(hexString.toCharArray()), "cp424");
eggyal
  • 122,705
  • 18
  • 212
  • 237