A few months ago I picked up a inexpensive pen-based MS-DOS laptop. It came with a Word Processor that handles handwritten input from the screen. I’ve found it usefull for taking notes at meetings and writing short letters while watching TV. The word processor stores it’s files in its own format and not ascii.
I’ve thought about the ways that I could get the file to ascii so I can transfer it to the QL and into Quill or MicroEmacs. The word processor will output an ascii version of the file, but I did not want to have to go throught the process for every file. Plus this means that every file would have an ascii version on disk that I would have to go back and delete. I wanted to convert the original file somehow.
Not knowing how the word processor stored its files, I decided a program could be written that would strip out all non-printable characters from a file, there by making it a pure text file.
Below is strip_c that does this. This program ignores any non-ascii characters and non-printing ascii characters (like null, etc). It does translate all Carriage Returns into Line Feeds that the QL prefers. It’s short, simple and to the point.
/* strip_c */
/* Will compile under Small-C */
#include <stdio_h>
main() {
char c, file1[30], file2[30];
int
fd1,
fd2;
printf("Enter Input File Name : \n");
gets(file1);
printf("Enter Output File Name: \n");
gets(file2);
fd1 = fopen(file1,"r");
if (fd1 == NULL) {
printf("Did not open file: %s",file1);
abort(1);
}
fd2 = fopen(file2,"w");
if (fd2 == NULL) {
printf("Did not open file: %s",file2);
abort(1);
}
while (( c = getc(fd1)) != EOF) {
if ( c >= 32 && c <= 126 )
{ putc(c,fd2); }
if ( c == 10 || c ==13 )
{ c = 10; putc(c,fd2); }
}
fclose(fd1);
fclose(fd2);
}