iachar(3f) - [FORTRAN:INTRINSIC:CHARACTER] Code in ASCII collating sequence
result = iachar(c [, kind])
iachar(c) returns the code for the ASCII character in the first character position of C.
C Shall be a scalar CHARACTER, with intent(in) KIND (Optional) An INTEGER initialization expression indicating the kind parameter of the result.
The return value is of type INTEGER and of kind KIND. If KIND is absent, the return value is of default integer kind.
Sample program:
program demo_iachar implicit none ! create function to convert uppercase letters to lowercase write(*,(a))lower(abcdefg ABCDEFG) contains ! elemental pure function lower(str) result (string) ! Changes a string to lowercase character(*), intent(In) :: str character(len(str)) :: string integer :: i string = str ! step thru each letter in the string in specified range do i = 1, len(str) select case (str(i:i)) case (A:Z) ! change letter to miniscule string(i:i) = char(iachar(str(i:i))+32) case default end select end do end function lower ! end program demo_iachar
See [[ichar]] for a discussion of converting between numerical values and formatted string representations.
[[Fortran 95]] and later, with KIND argument [[Fortran 2003]] and later
[[Elemental procedure|Elemental function]]
[[achar]], [[char]], [[ichar]]Functions that perform operations on character strings, return lengths of arguments, and search for certain arguments:
Elemental: adjustl(3), adjustr(3), index(3), len_trim(3), scan(3), verify(3) Nonelemental: repeat(3), trim(3)
iachar (3) | March 11, 2021 |