This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes manpulating Unicode values.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "manpulating Unicode values.." Watch "manpulating Unicode values.." New topic

manpulating Unicode values..

Muhammad Ahsan Jamshaid
Ranch Hand

Joined: Jun 01, 2006
Posts: 59

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

--Ahsan Jamshaid

--Ahsan Jamshaid... SCJP 5(80%)
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Cast to an int.
sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
I was going to suggest this:

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

but it displays 10 for me. What the??
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
No .. I said, cast it to a int.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14952

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Completely forgotten it

So do:
[ October 18, 2006: Message edited by: Bauke Scholtz ]
Have you checked out Aspose?
subject: manpulating Unicode values..
It's not a secret anymore!