34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
func Decode(Ch);
|
|
int Ch;
|
|
[if Ch>=^A & Ch<=^Z then return Ch - ^A;
|
|
if Ch>=^a & Ch<=^z then return Ch - ^a + 26;
|
|
if Ch>=^0 & Ch<=^9 then return Ch - ^0 + 52;
|
|
if Ch = ^+ then return 62;
|
|
if Ch = ^/ then return 63;
|
|
return -1;
|
|
];
|
|
|
|
char Str;
|
|
int Count, N, Ch, Code, Acc;
|
|
[Str:=
|
|
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEg
|
|
Y29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo ";
|
|
loop [Count:= 0;
|
|
for N:= 1 to 4 do \read in four 6-bit chars
|
|
[repeat Ch:= Str(0); \strip out whitespace
|
|
Str:= Str+1;
|
|
if Ch = $A0 then quit; \terminating space
|
|
until Ch > $20;
|
|
Code:= Decode(Ch);
|
|
Acc:= Acc<<6;
|
|
if Code >= 0 then \don't count possible "="
|
|
[Acc:= Acc + Code;
|
|
Count:= Count+1;
|
|
];
|
|
];
|
|
ChOut(0, Acc>>16); \write out three 8-bit chars
|
|
if Count >= 3 then ChOut(0, Acc>>8);
|
|
if Count >= 4 then ChOut(0, Acc);
|
|
];
|
|
]
|