RosettaCodeData/Task/URL-encoding/Liberty-BASIC/url-encoding.basic

24 lines
517 B
Plaintext

dim lookUp$( 256)
for i =0 to 256
lookUp$( i) ="%" +dechex$( i)
next i
string$ ="http://foo bar/"
print "Supplied string '"; string$; "'"
print "As URL '"; url$( string$); "'"
end
function url$( i$)
for j =1 to len( i$)
c$ =mid$( i$, j, 1)
if instr( "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", c$) then
url$ =url$ +c$
else
url$ =url$ +lookUp$( asc( c$))
end if
next j
end function