0

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?

penguina
  • 185
  • 2
  • 10

1 Answers1

2

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
    }
}
Davide Lorenzo MARINO
  • 26,420
  • 4
  • 39
  • 56