Created
August 22, 2020 21:12
-
-
Save michaelengel/79c0e998b53d460a8833d7e27f4a0692 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <stdint.h> | |
#include <string.h> | |
#define BASE 48 | |
#define STOP_BASE 35 | |
int main(void) { | |
char line[128]; | |
int factor; | |
int rest; | |
int div; | |
uint8_t c, byte; | |
gets(line); printf("%s\n", line); | |
gets(line); | |
factor = 1; | |
div = 256; | |
while (1) { | |
if (gets(line) == 0) break; | |
for (int i=0; i<strlen(line); i++) { | |
c = (uint8_t)line[i]; | |
if (c >= BASE + 64) break; | |
byte = c - BASE; | |
if (factor != 1) { | |
putchar(rest + (byte % div) * factor); | |
rest = byte / div; | |
div = div * 4; | |
factor = factor / 4; | |
} else { | |
rest = byte; | |
div = 4; | |
factor = 64; | |
} | |
} | |
} | |
byte = c - STOP_BASE; | |
int ok = ((byte == 0) & (div == 256)) | ((byte == 1) && (div = 16)) | ((byte == 2) && (div == 64) && (rest == 0)); | |
if (!ok) { | |
fprintf(stderr, "decode failed!\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A quick and dirty decoder to convert "AsciiCoder"-encoded (similar to base64) uncompressedd Oberon .Cod files to .Mod files