text in ASCII upper or lower case.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the text to convert |
||
| logical, | intent(in) | :: | upper |
true for upper case, false for lower case |
pure function to_case(text, upper) result(t) !! `text` in ASCII upper or lower case. character(len=*), intent(in) :: text !! the text to convert logical, intent(in) :: upper !! true for upper case, false for lower case character(len=len(text)) :: t integer :: k, c t = text do k = 1, len(t) c = iachar(t(k:k)) if (upper .and. c >= iachar('a') .and. c <= iachar('z')) t(k:k) = achar(c - 32) if (.not. upper .and. c >= iachar('A') .and. c <= iachar('Z')) t(k:k) = achar(c + 32) end do end function to_case