/* * Filter some odd characters that Scripsit uses. * Usage: scr2txt [-] < infile > outfile.txt * * Translations: * 0x00 (null) is dropped (only 1 ever seen) * 0x09 (tab) is unchanged, but the next character is dropped * 0x10 (start/end emphasis) to "_" * 0x89 (tab with high bit set) is changed to "\t" (tab) and * the next character is dropped * 0x8d (end of paragraph) to "\r\n", or "\r\n\r\n" if "-" argument given * 0xa0 (I don't know how this differs from a plain space) to " " (space) */ #include int main(int argc, char **argv) { int c; while ((c = getchar()) != EOF) { switch (c) { case 0x00: break; case 0x09: case 0x89: putchar('\t'); getchar(); /*drop next char*/ break; case 0x10: putchar('_'); break; case 0x8d: putchar('\r'); putchar('\n'); if (argc > 1) { putchar('\r'); putchar('\n'); } break; case 0xa0: putchar(' '); break; default: putchar(c); break; } } putchar('\r'); putchar('\n'); }