is_printable Function

public elemental function is_printable(c)

Checks whether or not c is a printable character - including the space character.

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(in) :: c

The character to test.

Return Value logical


Variables

Type Visibility Attributes Name Initial
integer, private :: ic

Source Code

   elemental logical function is_printable(c)
      character(len=1), intent(in) :: c
          !! The character to test.
      integer :: ic
      ic = iachar(c)
      !The character is printable if it's between ' ' and '~' in the ASCII table
      is_printable = ic >= iachar(' ') .and. ic <= int(z'7E')
   end function is_printable