ispunct(3f) - [M_strings:COMPARE] returns .true. if character is a
printable punctuation character
(LICENSE:PD)
elemental function ispunct(onechar)
character,intent(in) :: onechar
logical :: ispunct
ispunct(3f) returns .true. if character is a printable punctuation
character
onechar character to test
ispunct logical value returns true if character is a printable
punctuation character.
Sample program:
program demo_ispunct
use M_strings, only : ispunct
implicit none
integer :: i
character(len=1),parameter :: string(*)=[(char(i),i=0,127)]
write(*,'(20(g0,1x))')'ISPUNCT: ', &
& iachar(pack( string, ispunct(string) ))
write(*,'(20(g0,1x))')'ISPUNCT: ', &
& pack( string, ispunct(string) )
end program demo_ispunct
Results:
ISPUNCT: 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 58 59 60 61
62 63 64 91 92 93 94 95 96 123 124 125 126
ISPUNCT: ! " # $ % & ' ( ) * + , - . / : ; < =
> ? @ [ \ ] ^ _ ` { | } ~
John S. Urban
Public Domain
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in) | :: | ch |
elemental function ispunct(ch) result(res)
! ident_74="@(#) M_strings ispunct(3f) true if a printable punctuation character (isgraph(c)&&!isalnum(c))"
character,intent(in) :: ch
logical :: res
select case(ch)
case (char(33):char(47), char(58):char(64), char(91):char(96), char(123):char(126))
res=.true.
! case(' ','0':'9','A':'Z','a':'z',char(128):)
! res=.true.
! case(char(0):char(31),char(127))
! res=.true.
case default
res=.false.
end select
end function ispunct