[UP]


Manual Reference Pages  - noesc (3)

NAME

noesc(3f) - [M_strings:NONALPHA] convert non-printable characters to a space. (LICENSE:PD)

CONTENTS

Synopsis
Description
Examples
Author
License

SYNOPSIS

elemental function noesc(INSTR)

character(len=*),intent(in) :: INSTR character(len=len(instr)) :: noesc

DESCRIPTION

Convert non-printable characters to a space.

EXAMPLES

Sample Program:

   program demo_noesc

use M_strings, only : noesc character(len=128) :: ascii character(len=128) :: cleared ! fill variable with base ASCII character set do i=1,128 ascii(i:i)=char(i-1) enddo cleared=noesc(ascii) write(*,*)’characters and their ADE (ASCII Decimal Equivalent)’ call ade(ascii) write(*,*)’Cleared of non-printable characters’ call ade(cleared) write(*,*)’Cleared string:’ write(*,*)cleared contains subroutine ade(string) implicit none ! the string to print character(len=*),intent(in) :: string ! number of characters in string to print integer :: ilen ! counter used to step thru string integer :: i ! get trimmed length of input string ilen=len_trim(string(:len(string)))

! replace lower unprintable characters with spaces write(*,101)(merge(string(i:i),’ ’,& & ichar(string(i:i)).ge.32 & & .and. & & ichar(string(i:i)).le.126) & & ,i=1,ilen)

! print ADE value of character underneath it write(*,202) (ichar(string(i:i))/100, i=1,ilen) write(*,202)(mod( ichar(string(i:i)),100)/10,i=1,ilen) write(*,202)(mod((ichar(string(i:i))),10), i=1,ilen) ! format for printing string characters 101 format(*(a1:)) ! format for printing ADE values 202 format(*(i1:)) end subroutine ade end program demo_noesc

Expected output

The string is printed with the ADE value vertically beneath. The original string has all the ADEs from 000 to 127. After NOESC(3f) is called on the string all the "non-printable" characters are replaced with a space (ADE of 032).

characters and their ADE (ASCII Decimal Equivalent)

   >                                 !"#$%&’()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_‘abcdefghijklmnopqrstuvwxyz{|}~
   >00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111
   >00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222
   >01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567

Cleared of non-printable characters

   >                                 !"#$%&’()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_‘abcdefghijklmnopqrstuvwxyz{|}~
   >0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111
   >3333333333333333333333333333333333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222222
   >2222222222222222222222222222222223456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456

Cleared string:
> !"#$%&’()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_‘abcdefghijklmnopqrstuvwxyz{|}~

AUTHOR

John S. Urban

LICENSE

Public Domain


noesc (3) July 05, 2020
Generated by manServer 1.08 from eec0da9c-fb15-4795-9914-9c33bc7bae72 using man macros.