24 lines
623 B
Text
24 lines
623 B
Text
|
|
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/Транспайлер’))
|