ICHAR(3) - [CHARACTER:CONVERSION] Character-to-integer code conversion function
result = ichar(c [,kind])
elemental integer(kind=KIND) function ichar(c,KIND)character(len=1,kind=**),intent(in) :: c integer,intent(in),optional :: KIND
o C is a scalar character o KIND is a constant integer initialization expression indicating the kind parameter of the result. o The return value is of type integer and of kind KIND. If KIND is absent, the return value is of default integer kind.
ICHAR(3) returns the code for the character in the systems native character set. The correspondence between characters and their codes is not necessarily the same across different Fortran implementations. For example, a platform using EBCDIC would return different values than an ASCII platform.
See IACHAR(3) for specifically working with the ASCII character set.
o C : The input character to determine the code for. Its value shall be that of a character capable of representation in the processor. o KIND : indicates the kind parameter of the result. If KIND is absent, the return value is of default integer kind.
The code in the system default character set for the character being queried is returned.
The result is the position of C in the processor collating sequence associated with the kind type parameter of C.
it is nonnegative and less than n, where n is the number of characters in the collating sequence.
The kind type parameter of the result shall specify an integer kind that is capable of representing n.
For any characters C and D capable of representation in the processor, C <= D is true if and only if ICHAR (C) <= ICHAR (D) is true and C == D is true if and only if ICHAR (C) == ICHAR (D) is true.
Sample program:
program demo_ichar implicit noneResults:write(*,*)ichar([a,z,A,Z])
end program demo_ichar
97 122 65 90
Fortran 95 , with KIND argument -Fortran 2003
ACHAR(3), CHAR(3), IACHAR(3)
Functions that perform operations on character strings, return lengths of arguments, and search for certain arguments:
SCAN(3), VERIFY(3)
o ELEMENTAL: ADJUSTL(3), ADJUSTR(3), INDEX(3), fortran-lang intrinsic descriptions (license: MIT) @urbanjost
o NONELEMENTAL: LEN_TRIM(3), LEN(3), REPEAT(3), TRIM(3)
Nemo Release 3.1 | ichar (3fortran) | April 28, 2024 |