Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Base64-decode-data/XPL0/base64-decode-data.xpl0
Normal file
33
Task/Base64-decode-data/XPL0/base64-decode-data.xpl0
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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);
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue