[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More fun with Freed Z80



"AppleCPM" <a2@wilserv.com> wrote:

>Now to find my program for stripping off high order bits off ASCII 
>characters...

http://www.cpm8680.com/utl/undoc.zip

// --------------------------------------------------------------
// System       : WIN9X/NT
// Program      : undoc.c
// Description  : WordStar to Plain Text Filter
//
//   A filter which strips the 8 bit ascii formatting used
//   in files created in the old WordStar WordProcesser.
//
//   Output is in the form of plain text with formatting
//   removed. Tested with WordStar 3 and 4.
//
//   Leaves spacing in place.
//
// Written by   : Bill Buckels
// Date Written : 1989
// Revision     : 2.0 March 2000
//                3.0 January 2009 (orginal program was unws.c)
// --------------------------------------------------------------
#include <stdio.h>


void main(int argc, char **argv)
{
    int c;
    FILE *fp = NULL;

    if (argc > 1)
      fp = fopen(argv[1], "rb");

    for (;;)
    {
      if (NULL == fp)
        c = getchar();
      else
        c = fgetc(fp);

      if (c==EOF)break;

      // if CTRL-Z found, EOF
      if (c == 0x1a)
        break;
      // 7 bit ascii
       c = c&0x7f;
      // skip lower order characters except for line feeds and tabs
      if (c > 31 || c == '\n' || c == '\t')
        putchar(c);

    }
    if (fp != NULL) {
      fclose(fp);
      exit(0);
    }
}