arnold@gatech.UUCP (Mister Snuffle-upagus) (12/12/84)
A while back I posted a cute little program to translate from regular ascii to CDC Cyber 6/12 code (you know, the ugly '^A' for a lower case 'a'), etc. Well the need has come up to go the other way, so here is the program to translate from Cyber 6/12 ascii to regular ascii. I call it 'uncyber.c'. Don't forget the signature at the end of the article. Enjoy, Arnold Robbins ------------------ cut here --------------- /* uncyber --- map display code (ugh) into ascii equivalents */ /* Arnold Robbins, December 1984, Georgia Tech */ /* gatech!arnold */ #include <stdio.h> #include <ctype.h> /* definitions of ASCII mnemonics */ #define NUL '\0' #define SOH '\001' #define STX '\002' #define ETX '\003' #define EOT '\004' #define ENQ '\005' #define ACK '\006' #define BEL '\007' #define BS '\010' #define HT '\011' #define LF '\012' #define VT '\013' #define FF '\014' #define CR '\015' #define SO '\016' #define SI '\017' #define DLE '\020' #define DC1 '\021' #define DC2 '\022' #define DC3 '\023' #define DC4 '\024' #define NAK '\025' #define SYN '\026' #define ETB '\027' #define CAN '\030' #define EM '\031' #define SUB '\032' #define ESC '\033' #define FS '\034' #define GS '\035' #define RS '\036' #define US '\037' #define SP '\040' #define DEL '\177' int cur_line = 1; main () { int c; extern int uparrow (), at (); while ((c = getchar()) != EOF) { switch (c) { case '^': putchar (uparrow (getchar())); break; case '@': putchar (at (getchar())); break; case '\n': cur_line++; /* fall through */ default: putchar (c); break; } } exit (0); } /* uparrow --- look at the char after the '^' and put out the right thing */ int uparrow (c) int c; { switch (c) { case '5': return (NUL); break; case '6': return (SOH); break; case '7': return (STX); break; case '8': return (ETX); break; case '9': return (EOT); break; case '+': return (ENQ); break; case '-': return (ACK); break; case '*': return (BEL); break; case '/': return (BS); break; case '(': return (HT); break; case '$': return (VT); break; case '=': return (FF); break; case ' ': return (CR); break; case ',': return (SO); break; case '.': return (SI); break; case '#': return (DLE); break; case '[': return (DC1); break; case ']': return (DC2); break; case '%': return (DC3); break; case '"': return (DC4); break; case '_': return (NAK); break; case '!': return (SYN); break; case '&': return (ETB); break; case '\'': return (CAN); break; case '?': return (EM); break; case '<': return (SUB); break; case '>': return (ESC); break; case '@': return (FS); break; case '\\': return (GS); break; case '^': return (RS); break; case ';': return (US); break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': return (tolower (c)); break; case '0': return ('{'); break; case '1': return ('|'); break; case '2': return ('}'); break; case '3': return ('~'); break; case '4': return (DEL); break; default: fprintf (stderr, "line %d: character '%c' (0%o) unexpected after '^'\n", cur_line, c, c); exit (1); break; } } /* at --- look at the char after the '@' and put out the right thing */ at (c) int c; { switch (c) { case 'A': return ('@'); break; case 'B': return ('^'); break; case 'D': return (':'); break; case 'G': return ('`'); break; default: fprintf (stderr, "line %d: character '%c' (0%o) unexpected after '@'\n", cur_line, c, c); exit (1); break; } } -- Arnold Robbins CSNET: arnold@gatech ARPA: arnold%gatech.csnet@csnet-relay.arpa UUCP: { akgua, allegra, hplabs, ihnp4 }!gatech!arnold !gitpyr!arnold !stratus!nimbus!arnold Can you tell me how to get, how to get to Sesame Street?