home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CONVCHAR.ZIP
/
CONVCHAR.DOC
< prev
next >
Wrap
Text File
|
1989-06-12
|
3KB
|
57 lines
ConvChar is a DOS filter that reads and copies its input from stdin to
stdout, converting a selected character to another in the copy operation.
It requires two arguments, the decimal values of the characters to convert.
As with all DOS filters, you must supply at least the input file or source
to read the characters, or it will read from stdin, the keyboard.
Running ConvChar without its two required parameters gives a help message:
ConvChar is a DOS filter to convert single character values globally
to another character value. Usage:
ConvChar fromchar tochar <source >dest Where:
fromchar is the decimal value of the character to convert
tochar is the decimal value of the character to replace
source is the Ascii source file
dest is the Ascii destination file
ConvChar 0 255 <olddoc >newdoc
Reads & copies OLDDOC file to NEWDOC, converting chars valued 0 to value 255
ConvChar 255 0 <newdoc >newerdoc
Reverses above, reads NEWDOC, converts 255 value chars back to 0 on NEWERDOC
DIR /W | ConvChar 9 32
Converts all tab chars from DIR /W (value 9) to a single space (value 32)
ConvChar was written by Steve Kraus as a utility in response to a question:
How do you run DIFF on a file with embedded [NUL] characters? The answer
is to run the source document(s) through some kind of preprocessor to
convert all those NUL characters to some other character value. If you
have some kind of formatted document created by a word processor that
leaves NUL value formatting codes embedded in the output, DIFF will treat
those embedded NUL (0 value) characters as end of strings.
This isn't exactly an elegant solution, but it works. If you wish to
convert two files with embedded NULS: MyDoc1.PRN and MyDoc2.PRN, first
convert both files to temporary files for comparison. Use ConvChar to
change the NUL chars to 255, which usually displays and prints as a space.
(I use 255, but experiment with your own character value). Run the
resulting files through DIFF, then convert the change bar file generated,
changing 255 valued characters back to 0 for printing. It will probably be
necessary to fix the change bar locations in the resulting file, because
DIFF treats 255 valued characters as if they occupy a space.
ConvChar 0 255 <MyDoc1.PRN >MyDoc1 <-- convert & copy MyDoc1 & 2
ConvChar 0 255 <MyDoc2.PRN >MyDoc2
DIFF -b 78 MyDoc1 MyDoc2 BarDoc <-- compare & make a change
bar file
ConvChar 255 0 <BarDoc >BarDoc.PRN <-- convert embedded 255 chars
back to NUL (0) for printing
ZDEL MyDoc1 MyDoc2 BarDoc <-- delete scratch files
This utility is hereby released into public domain. Have fun,
Steve Kraus - 12 June 1989.