I am trying to create an Android application that converts regular hexadecimal code to inverted, which is used in smali. Everything works fine, except when I use the replace or replaceAll method for String, it even replaces characters that have already been replaced
For example,
String stringInvert = string.replace("F", "0")
.replace("E" , "1")
.replace("D" , "2")
.replace("C" , "3")
.replace("B" , "4")
.replace("A" , "5")
.replace("9" , "6")
.replace("8" , "7")
.replace("7" , "8")
.replace("6" , "9")
.replace("5" , "A")
.replace("4" , "B")
.replace("3" , "C")
.replace("2" , "D")
.replace("1" , "E")
.replace("0" , "F");
As you can see, the first F changes to 0, and similarly the other letters also change, but later 0 changes to F, which also changes the already changed F to F. Thus, in general, only letters / numbers that before 7 are addressed ( how they are replaced in the code), while others remain the same due to double inversion. I even tried the replaceAll method, it gives the same result. So is there any other way or work on this issue?
- http://pastebin.com/dB23JmQG
, , AIDE