-D said:
How do you evaluate a string as unicode literal? That is,
how do you convert "\u004E" (normal string) to '\u004E' (character literal)?
The only way I can make any sense of your post is if you mean
public class Eval {
// note the double backslash
static final String normalString = "\\u004E";
static final char literalCharacter = evaluateString(normalString);
// argument must contain "\\uXXXX" exactly
// first is a backslash '\\', second is a lowercase 'u'
// ande XXXX is a unicode character id
static char evaluateString(String s) {
// insert code here
return (char)Integer.parseInt(s.substring(2),0x10);
}
public static void main(String[] arg) {
System.out.println(literalCharacter);
}
}
Improving the evaluateString() to take arguments of varying format
is left as an exercise for the OP.