Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View 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/"

View file

@ -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}}")),
)
}

View 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