RosettaCodeData/Task/URL-encoding/11l/url-encoding.11l

24 lines
623 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
F url_encode(s)
V r =
V buf =
F flush_buf() // this function is needed because strings in 11l are UTF-16 encoded
I @buf !=
V bytes = @buf.encode(utf-8)
L(b) bytes
@r = %hex(b).zfill(2)
@buf =
L(c) s
I c C (0..9, a..z, A..Z, _, ., -, ~)
flush_buf()
r = c
E
buf = c
flush_buf()
R r
print(url_encode(http://foo bar/))
print(url_encode(https://ru.wikipedia.org/wiki/Транспайлер’))