IACHAR intrinsic function

Standard: F77 F90 F95 F2003 F2008 F2018


<Syntax>

IACHAR ( C [ , KIND ] )

C : Character with length one;
KIND : scalar Integer constant expression;

Result : Integer or Integer(Kind=KIND).

<Semantics>

Convert single Character value to ASCII character code; this is the inverse of the ACHAR intrinsic function. Like many intrinsic functions, this is elemental; the result has the same shape as C, with the operation being applied elementwise.

Fortran 2003 adds the optional KIND argument; this is totally useless since every character set in the world can be represented in a default Integer and ASCII itself only goes up to 127.

WARNING: If the character is not in the ASCII character set, the result is not defined; this means that ACHAR(CHAR(X)) might not give you back the original value of X, and indeed that just because the return value is in the range 0-127 does not mean that the character is actually an ASCII character. That means it is risky to use this when processing European characters (the ISO 8859-n family), and it is totally unsuitable for processing Japanese (JIS 0213) or Unicode (ISO/IEC 10646) characters.

<Related>

ACHAR intrinsic function, CHAR intrinsic function, CHARACTER type, ICHAR intrinsic function