Reputation: 185
I have the following case :
java Myprog \u03b1
And I want to read alpha value(that unicode) in a char. How could I do this in Java?
Upvotes: 0
Views: 86
Reputation: 26926
You can read the string (without \u) as an integer in hexadecimal format.
And convert it to char
.
public class Myprog {
public static void main(String[] args) {
char c = (char) Integer.parseInt(args[0].substring(2), 16 );
// Use char as you like
}
}
Upvotes: 2