Skip to content

Instantly share code, notes, and snippets.

@skreuzer
Created October 27, 2010 02:56
Show Gist options
  • Save skreuzer/648339 to your computer and use it in GitHub Desktop.
Save skreuzer/648339 to your computer and use it in GitHub Desktop.
function x(l, p) {
n = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_";
return index(n, substr(l, p + 1, 1));
}
/^begin/ {}
/^[^be]/ {
len = x(\$0, 0);
for(i = 1; len > 0; i += 4) {
a = x(\$0, i);
b = x(\$0, i + 1);
c = x(\$0, i + 2);
d = x(\$0, i + 3);
printf("%c", a * 4 + b / 16);
if(len > 1) {
printf("%c", b * 16 + c / 4);
if(len > 2) {
printf("%c", c * 64 + d);
}
}
len -= 3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment