3

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

8

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:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm#apex_System_String_getChars

You must log in to answer this question.

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