Created
May 8, 2015 05:36
-
-
Save tomdwaggy/25320bc8fe68b4c35c42 to your computer and use it in GitHub Desktop.
Konwort Script for CP437
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <locale.h> | |
#include <wchar.h> | |
int ibm[256] = { | |
0, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, 0x25d8, | |
0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c, 0x25ba, | |
0x25c4, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25ac, 0x21a8, 0x2191, | |
0x2193, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc, 32, 33, 34, 35, | |
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, | |
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, | |
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, | |
84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, | |
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, | |
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, | |
126, 0x2302, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, | |
0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, | |
0x00c5, 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, | |
0x00f9, 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, | |
0x0192, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, | |
0x00aa, 0x00ba, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, | |
0x00bb, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, | |
0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, | |
0x2510, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, | |
0x255f, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, | |
0x2567, 0x2568, 0x2564, 2565, 0x2559, 0x2558, 0x2552, 0x2553, | |
0x256b, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, | |
0x2580, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, | |
0x03c4, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, | |
0x2229, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, | |
0x2248, 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, | |
0x00a0 | |
}; | |
int main() { | |
int i, e; | |
char p; | |
char buffer[255]; | |
char* esc; | |
setlocale(LC_ALL, ""); | |
do { | |
p = (char) fgetc(stdin); | |
if (p == '\e') { | |
esc = buffer; | |
do { | |
*esc++ = (char) fgetc(stdin); | |
} while ( | |
*(esc - 1) != 'H' && | |
*(esc - 1) != 'f' && | |
*(esc - 1) != 'A' && | |
*(esc - 1) != 'B' && | |
*(esc - 1) != 'C' && | |
*(esc - 1) != 'D' && | |
*(esc - 1) != 's' && | |
*(esc - 1) != 'u' && | |
*(esc - 1) != 'J' && | |
*(esc - 1) != 'K' && | |
*(esc - 1) != 'm' && | |
*(esc - 1) != 'h' && | |
*(esc - 1) != 'l' && | |
*(esc - 1) != 'p' | |
); | |
char replaced = *esc; | |
*(esc) = '\0'; | |
wprintf(L"%s%s", "\33", buffer); | |
//fputwc(ibm[replaced], stdout); | |
} else if(p == '\n') { | |
fputwc(L'\n', stdout); | |
} else if(p == 13) { | |
} else { | |
fputwc(ibm[(unsigned char) p], stdout); | |
} | |
} while (p != EOF); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment