I want to replace "\u0023 \u0024 ab" with: "\\u0023 \\u0024 ab" to maintain its encoding before storing it in database.
There can me many different values after \u, not just 0023, 0024.
I tried using str.replace("\"\\"); or ("\u","\\u") but it doesn't work in java because it treats \u0023 as one character.
Any suggestions how to achieve this ?
I tried like this
public class test {
public static void main(String args[]) {
String s = "\u0023";
s = s.replace("\\", "\\\\");
System.out.println(s);
}
}
but it is giving following output as:
#
but I am expecting:
\\u0023