How can i convert (in APEX) a String to an Integer, which corresponds to its ASCII.

What I have:

String Name = 'A';

What I want:

Integer Number = 65;

Thanks all!

1 Answer 1


The string.getChars() method works for this:

Integer[] vals;
String tmp = 'This is a test';
vals = tmp.getChars();

Documented in the official documentation in SF with an example of doing just this:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .