Code Files

rtf2txt.awk

Generated on Tue Dec 05 17:39:06 Eastern Standard Time 2006 from rtf2txt.awk


# Program : RTF2TXT.AWK
# Purpose : Convert the SUBDUMP.RTF file created
#           by GWCHECK 6.5.7 and convert to single-byte ASCII
# Date    : 4 October 2006
# Author  : Bob Jonkman <bjonkman@sobac.com>

# Copyright 2008 Bob Jonkman and/or SOBAC Microcomputer Services

#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.


function get2bytes(string,pointer,    first,second)    {
                first = substr(string,pointer,1) ;
                second = substr(string,pointer+1,1) ;

#               print("##### DEBUG ##### First=" first " = " first+0 " second=" second " = " second+0 )
                
                if (second == "\x00")    # check for non-printable ASCII
                {   return(first)
                } else
                {
                   return("??RTF??")    # cf. ??WTF?? :-) I tried hard to select a uniquely identifiable string...
                }
}


BEGIN       {   RS = "\x0d\x00\x0a\x00" ;     # Two-byte chars for CRLF
                ORS = "" ;
}

FNR == 1    {   inputpointer = 3 ;     # skip initial FF FE
}

            {
# print("\n##### DEBUG ##### $0=" $0)
                while (inputpointer < length($0))
                {
#                    print("\n##### DEBUG ##### FNR=" FNR " inputpointer=" inputpointer " :")
                    print(get2bytes($0,inputpointer)) ;
                    inputpointer += 2 ;
                }
                print("\n") ;
                inputpointer = 1 ;
                
}           


# EOF: RTF2TXT.AWK

   

1 files processed.