18 lines
503 B
Plaintext
18 lines
503 B
Plaintext
sub encode_url$(s$, exclusions$, spaceplus)
|
|
local res$, i, ch$
|
|
|
|
for i=1 to len(s$)
|
|
ch$ = mid$(s$, i, 1)
|
|
if ch$ = " " and spaceplus then
|
|
ch$ = "+"
|
|
elsif not instr(esclusions$, ch$) and (ch$ < "0" or (ch$ > "9" and ch$ < "A") or (ch$ > "Z" and ch$ < "a") or ch$ > "z") then
|
|
res$ = res$ + "%"
|
|
ch$ = upper$(hex$(asc(ch$)))
|
|
end if
|
|
res$ = res$ + ch$
|
|
next i
|
|
return res$
|
|
end sub
|
|
|
|
print encode_url$("http://foo bar/")
|