PDA

Click to See Complete Forum and Search --> : Getting Ascii code


cognito
Aug 1st, 2000, 09:17 PM
Anybody know if there's a function to get the ascii value for a character? Like in VB, you can do Asc("a") or whatever.

parksie
Aug 2nd, 2000, 02:03 PM
Since Java is all Unicode, that's what it will return, although you can use String.charAt(index):

String sMyString = "A string";
char cNumber = sMyString.charAt(0);

cNumber now contains the Unicode character code for 'A'. A simple translation array would probably be a much better bet for doing this, though.

[Edited by parksie on 08-02-2000 at 03:07 PM]