• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

manpulating Unicode values..

 
Muhammad Ahsan Jamshaid
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How can i print the unicode value of the character using in programm..

--Ahsan Jamshaid
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cast to an int.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going to suggest this:

char ch = 'a';
int code = Character.getNumericValue(ch);
System.out.println(code);

but it displays 10 for me. What the??
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No .. I said, cast it to a int.

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15481
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sven's solution is probably not what Muhammad is looking for (read the API documentation of Character.getNumericValue(...) - it doesn't return the Unicode value of the character).

Bauke's solution is right, but it doesn't output "1234", but 4660, because the number is printed in decimal, not in hexadecimal.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Completely forgotten it

So do:
[ October 18, 2006: Message edited by: Bauke Scholtz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic