Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/URL-encoding/XPL0/url-encoding.xpl0
Normal file
21
Task/URL-encoding/XPL0/url-encoding.xpl0
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
code Text=12;
|
||||
string 0; \use zero-terminated strings
|
||||
|
||||
func Encode(S0); \Encode URL string and return its address
|
||||
char S0;
|
||||
char HD, S1(80); \BEWARE: very temporary string space returned
|
||||
int C, I, J;
|
||||
[HD:= "0123456789ABCDEF"; \hex digits
|
||||
I:= 0; J:= 0;
|
||||
repeat C:= S0(I); I:= I+1;
|
||||
if C>=^0 & C<=^9 ! C>=^A & C<=^Z ! C>=^a & C<=^z ! C=0
|
||||
then [S1(J):= C; J:= J+1] \simply pass char to S1
|
||||
else [S1(J):= ^%; J:= J+1; \encode char into S1
|
||||
S1(J):= HD(C>>4); J:= J+1;
|
||||
S1(J):= HD(C&$0F); J:= J+1;
|
||||
];
|
||||
until C=0;
|
||||
return S1;
|
||||
];
|
||||
|
||||
Text(0, Encode("http://foo bar/"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue