Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/URL-decoding/M2000-Interpreter/url-decoding.m2000
Normal file
25
Task/URL-decoding/M2000-Interpreter/url-decoding.m2000
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue