Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/URL-encoding/11l/url-encoding.11l
Normal file
23
Task/URL-encoding/11l/url-encoding.11l
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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/Транспайлер’))
|
||||
Loading…
Add table
Add a link
Reference in a new issue