I am new to Java and have been battling this problem with google-fu ad experimentation for the last hour. I need to convert s1 to s2, where s1 and s2 are:
String s1 ="\\u00C1";
//...
String s2 ="Á";
I am new to Java and have been battling this problem with google-fu ad experimentation for the last hour. I need to convert s1 to s2, where s1 and s2 are:
String s1 ="\\u00C1";
//...
String s2 ="Á";
You need to scan the string to find the "\u" part, then extract the following four characters into a separate string, then use Integer.parseInt(String s, int radix)
with a radix of 16 to convert 00C1
to an int
, and then cast that int
to char
.
$ cat Test.java
public class Test {
public static void main(String[] args) {
String s = "\u00C1";
System.out.println(s);
}
}
$ javac Test.java
$ java Test
Á
automatically