Manual Reference Pages  - expand (3m_strings)

NAME

expand(3f) - [M_strings:NONALPHA] expand C-like escape sequences (LICENSE:PD)

CONTENTS

Synopsis
Description
Examples
Author
License

SYNOPSIS

function expand(line,escape) result(lineout)

   character(len=*)                      :: line
   character(len=1),intent(in),optional  :: escape
   character(len=:),allocatable          :: lineout

DESCRIPTION

EXPAND() expands sequences used to represent commonly used escape sequences or control characters. By default ...

Escape sequences

      \      backslash
      a      alert (BEL) -- g is an alias for a
      b      backspace
      c      suppress further output
      e      escape
      f      form feed
      n      new line
      r      carriage return
      t      horizontal tab
      v      vertical tab
      oNNN   byte with octal value NNN (3 digits)
      dNNN   byte with decimal value NNN (3 digits)
      xHH    byte with hexadecimal value HH (2 digits) -- h is an alias for x

The default escape character is the backslash, but this may be changed using the optional parameter ESCAPE.

EXAMPLES

Sample Program:

   program demo_expand
      use M_strings, only : expand
      integer,parameter     :: iwidth=1024
      integer               :: i
      character(len=iwidth),parameter :: input(*)=[ character(len=iwidth) :: &
         ’\e[H\e[2J’,&
         ’\tABC\tabc’,&
         ’\tA\a’,&
         ’\nONE\nTWO\nTHREE’,&
         ’\#146;]
         write(*,’(a)’)(trim(expand(input(i))),i=1,size(input))
   end program demo_expand

Results (with nonprintable characters shown visible):

    > ^[[H^[[2J
    > ^IABC^Iabc
    > ^IA^G
    >
    > ONE
    > TWO
    > THREE
    > \

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 expand (3m_strings) July 20, 2024
Generated by manServer 1.08 from 2f00df6d-7a94-4733-ad9b-6133a62a501d using man macros.