File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Ascii value for a Char

 
Yakubu Lawan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, I can't seem to find any function to get the ascii value of a Character e.g. 'A' is 65...
and also a function to convert decimal to hexadecimal.
Thanks.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There might be a function but I am not sure. You can just cast your character to an int though, as in...
System.out.println("A is : " + (int)'A');
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13049
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For characters in the ASCII range 0 - 127, the value in a Unicode char is the same as ASCII. You can cast it to a byte or int.
For a function to format an int as a hexidecimal or other base string, look at the Integer class static methods.
String s = Integer.toHexString( myint )
Bill
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved from Servlets -> Java In General - Beginner
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic