charAsInt()
EGL maintains the strLib.charAsInt() system function for compatibility with I4GL.
The function returns the code point (numeric representation) of
a character as an INT, based on the local character set where the
function runs:
- In ASCII environments, the function returns the ASCII code for the character.
- In EBCDIC environments, the function returns the EBCDIC code.
The complementary function strLib.intAsChar() returns the character to which a code point refers.
Syntax
strLib.charAsInt(character CHAR(1)? in)
returns (code INT?)
- character
- Input can be any variable or expression that is assignment compatible with the CHAR(1) type. For example, you can use a STRING variable as input, but only the first character is evaluated.
- code
- The decimal ASCII or EBCDIC (depending on your environment) value of character is returned as an INT. If character is null, the function returns a null value.
Example
source STRING = "ABC";
result INT?;
result = strLib.charAsInt(source);
// result is 65 on ASCII
// 193 on EBCDIC
Compatibility considerations
| Platform | Issue |
|---|---|
| JavaScript™ generation | The function strLib.charAsInt() is not supported |