aspose file tools*
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
Author

manpulating Unicode values..

Muhammad Ahsan Jamshaid
Ranch Hand

Joined: Jun 01, 2006
Posts: 59
Hi,

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);
System.out.println(code);

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: 13875
    
  10

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: manpulating Unicode values..
 
Similar Threads
identifiers
On Assertions
java is ASCII or Unicode ??
Is ch\u0061 a='a' a valid declaration?
Byte order and file transference.