Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
21
Task/URL-encoding/EasyLang/url-encoding.easy
Normal file
21
Task/URL-encoding/EasyLang/url-encoding.easy
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
func$ tohex h .
|
||||
for c in [ h div 16 h mod 16 ]
|
||||
c += 48
|
||||
if c >= 58 : c += 7
|
||||
r$ &= strchar c
|
||||
.
|
||||
return r$
|
||||
.
|
||||
func$ urlenc s$ .
|
||||
for c$ in strchars s$
|
||||
c = strcode c$
|
||||
if c >= 48 and c <= 57 or c >= 65 and c <= 90 or c >= 97 and c <= 122
|
||||
#
|
||||
else
|
||||
c$ = "%" & tohex c
|
||||
.
|
||||
r$ &= c$
|
||||
.
|
||||
return r$
|
||||
.
|
||||
print urlenc "http://foo bar/"
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
val urlEncode = fn(s) {
|
||||
replace(
|
||||
s, re/[^A-Za-z0-9]/,
|
||||
fn s:join("", map(fn b:"%{{b:X02}}", s2b(s))),
|
||||
s,
|
||||
by=re/[^A-Za-z0-9]/,
|
||||
with=fn r:join(map(s2b(r), by=fn b:"%{{b:X02}}")),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
7
Task/URL-encoding/Standard-ML/url-encoding.ml
Normal file
7
Task/URL-encoding/Standard-ML/url-encoding.ml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fun urlEncode str =
|
||||
let
|
||||
fun charToHex c = "%" ^ (Int.fmt StringCvt.HEX (ord c))
|
||||
fun escapeChar c = if Char.isAlphaNum c then Char.toString c else charToHex c
|
||||
in
|
||||
String.concat (map escapeChar (explode str))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue