Hi all
I need to print unicodes of A-Z in java.
How do i print the unicode of a character in java.
Abdul khaliq
Hi all
I need to print unicodes of A-Z in java.
How do i print the unicode of a character in java.
Abdul khaliq
int CharCode = (int)'a';
Or:
System.out.println((int)'a');
So for your example:
for (char c='A'; c <= 'Z'; c++) { System.out.println(c + ": " + (int)c); }
If you are interested in the unicode numbers of the letters you can do the following (here for the letter 'x'):
byte[] bytes = "x".getBytes( "UTF-16" );
System.out.println( String.format("%0" + (bytes.length * 2) + "X",
new BigInteger( 1, bytes )) );
This will output:
FEFF0078
For UTF-8 and other letters simply change the first line.