/* Sanitise.c - version 0.0.2 * * No license whatsoever, use entirely at own risk * * reads from stdin, replaces windoze 1252 characters with ascii equivalents, * keeps everything else the same, writes to stdout. * Lots more useful fixes to come */ #include #define HTML 0 #define TEXT 1 int mode=TEXT; int main(int argc, char * argv[]) { int current; char * quote66, * quote99, * bullet, * ndash, * mdash; if (mode==HTML) { quote66="”"; quote99="“"; bullet="•"; ndash="–"; mdash="—"; } else { quote66="\""; quote99="\""; bullet="."; ndash="-"; mdash="-"; } while (!feof(stdin)) { current = fgetc(stdin); if (current==EOF) break; switch (current) { case 0x60: case 0x91: fputc('`',stdout); break; case 0xB4: case 0x92: fputc('\'',stdout); break; case 0x93: fprintf(stdout,quote66); break; case 0x94: fprintf(stdout,quote99); break; case 0x95: fprintf(stdout,bullet); break; case 0x96: fprintf(stdout,ndash); break; case 0x97: fprintf(stdout,mdash); break; case 0xA6: fputc('|',stdout); break; default: fputc(current,stdout); } } return 0; }