expand(3f) - [M_strings:NONALPHA] expand C-like escape sequences (LICENSE:PD)
Synopsis
Description
Examples
Author
License
function expand(line,escape) result(lineout)
character(len=*) :: line character(len=1),intent(in),optional :: escape character(len=:),allocatable :: lineout
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.
Sample Program:
program demo_expand ! test filter to expand escape sequences in input lines use M_strings, only : expand character(len=1024) :: line integer :: ios READFILE: block do read(*,(A),iostat=ios)line if(ios /= 0) exit READFILE write(*,(a))trim(expand(line)) enddo endblock READFILE end program demo_expandSample input:
\e[2J \tABC\tabc \tA\a \nONE\nTWO\nTHREE
John S. Urban
Public Domain
expand (3) | March 11, 2021 |