#include /* * Russian (KOI-8) to English (ASCII) translator. * Acts as a filter. * If started `rtol c' translates KOI-8 with 8th bit cut. */ char *rtol[] = { "yu", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "ya", "r", "s", "t", "u", "zh", "v", "'", "y", "z", "sh", "e", "sch", "ch", "`" }; char *RtoL[] = { "Yu", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Ya", "R", "S", "T", "U", "Zh", "V", "'", "Y", "Z", "Sh", "E", "Sch", "Ch", "`" }; main(int argc, char **argv) { int c; int conv; /* conv = (((argc>=1) && (argv[1][0]=='c')) ? 1 : 0); */ conv=0; while((c=getchar())!=EOF) { if(c>=0x80+'@' && c<=0x80+'_') { printf(rtol[c-0x80-'@']); } else if(c>=0x80+'`' && c<=0x80+0x7f) { printf(RtoL[c-0x80-'`']); } else if(conv && c>='@' && c<='_') { printf(rtol[c-'@']); } else if(conv && c>='`' && c<=0x7f) { printf(RtoL[c-'`']); } else { putchar(c); } } }