This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 14074

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 7 API documentation
Scala Notes - My blog about Scala
Bauke Scholtz
Ranch Hand

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

So do:
[ October 18, 2006: Message edited by: Bauke Scholtz ]
Don't get me started about those stupid light bulbs.
subject: manpulating Unicode values..
Similar Threads
Byte order and file transference.
java is ASCII or Unicode ??
Is ch\u0061 a='a' a valid declaration?
On Assertions