26 lines
1.1 KiB
Plaintext
26 lines
1.1 KiB
Plaintext
Module CheckIt {
|
|
Function decodeUrl$(a$) {
|
|
DIM a$()
|
|
a$()=Piece$(a$, "%")
|
|
if len(a$())=1 then =str$(a$):exit
|
|
k=each(a$(),2)
|
|
\\ convert to one byte per character using str$(string)
|
|
acc$=str$(a$(0))
|
|
While k {
|
|
\\ chr$() convert to UTF16LE
|
|
\\ str$() convert to ANSI using locale (can be 1033 we can set it before as Locale 1033)
|
|
\\ so chr$(0x93) give 0x201C
|
|
\\ str$(chr$(0x93)) return one byte 93 in ANSI as string of one byte length
|
|
\\ numbers are for UTF-8 so we have to preserve them
|
|
acc$+=str$(Chr$(Eval("0x"+left$(a$(k^),2)))+Mid$(a$(k^),3))
|
|
}
|
|
=acc$
|
|
}
|
|
\\ decode from utf8
|
|
final$=DecodeUrl$("google.com/search?q=%60Abdu%27l-Bah%C3%A1")
|
|
Print string$(final$ as utf8dec)="google.com/search?q=`Abdu'l-Bahá"
|
|
final$=DecodeUrl$("http%3A%2F%2Ffoo%20bar%2F")
|
|
Print string$(final$ as utf8dec)="http://foo bar/"
|
|
}
|
|
CheckIt
|