// A Somewhat more refined ASCII to Hollerith Code Converter // Based on a conversion table developed by Prof. Doug Jones // Micheal H. McCabe // Retrochallenge 2022/10 // October 2, 2022 #include #include using namespace std; #define ERROR 9999 int o29_code[] = { ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* control */ ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* chars */ ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* control */ ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* chars */ 00000,02202,00006,00102,02102,01042,04000,00022, /* !"#$%&' */ 04022,02022,02042,04012,01102,02000,04102,01400, /* ()*+,-./ */ 01000,00400,00200,00100,00040,00020,00010,00004, /* 01234567 */ 00002,00001,00202,02012,04042,00012,01012,01006, /* 89:;<=>? */ 00042,04400,04200,04100,04040,04020,04010,04004, /* @ABCDEFG */ 04002,04001,02400,02200,02100,02040,02020,02010, /* HIJKLMNO */ 02004,02002,02001,01200,01100,01040,01020,01010, /* PQRSTUVW */ 01004,01002,01001,04202,02006,01202,04006,01022, /* XYZ[\]^_ */ ERROR,04400,04200,04100,04040,04020,04010,04004, /* `abcdefg */ 04002,04001,02400,02200,02100,02040,02020,02010, /* hijklmno */ 02004,02002,02001,01200,01100,01040,01020,01010, /* pqrstuvw */ 01004,01002,01001,ERROR,ERROR,ERROR,ERROR,ERROR /* xyz{|}~ */ }; void PrintBinary(int Value) { if (Value>0 && Value<4096) { cout << "Hollerith Code: "; int m=2048; for (int j=11; j>=0; j--) { int bit=Value/m; Value=Value-bit*m; if (bit==1) cout << "1"; if (bit==0) cout << "0"; m=m/2; } cout << endl; } return; } int main() { string ascii; cout << "ASCII Text to Hollerith Code" << endl; cout << "Micheal H. McCabe" << endl; cout << "October 2, 2022" << endl; cout << endl; cout << "Please enter a line of ASCII text for conversion to Hollerith Code." << endl << endl; cout << ">"; getline (cin,ascii); cout << endl; int len = ascii.length(); cout << "Line length is " << len << " characters." << endl << endl; for (int i=0; i