Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,6 +1,8 @@
|
|||
This task (the reverse of [[URL encoding]]) is to provide a function
|
||||
This task (the reverse of [[URL encoding]] and distinct from [[URL parser]]) is to provide a function
|
||||
or mechanism to convert an URL-encoded string into its original unencoded form.
|
||||
|
||||
'''Example'''
|
||||
'''Test cases'''
|
||||
|
||||
The encoded string "<code><nowiki>http%3A%2F%2Ffoo%20bar%2F</nowiki></code>" should be reverted to the unencoded form "<code><nowiki>http://foo bar/</nowiki></code>".
|
||||
*The encoded string "<code><nowiki>http%3A%2F%2Ffoo%20bar%2F</nowiki></code>" should be reverted to the unencoded form "<code><nowiki>http://foo bar/</nowiki></code>".
|
||||
|
||||
*The encoded string "<code><nowiki>google.com/search?q=%60Abdu%27l-Bah%C3%A1</nowiki></code>" should revert to the unencoded form "<code><nowiki>google.com/search?q=`Abdu'l-Bahá</nowiki></code>".
|
||||
|
|
|
|||
12
Task/URL-decoding/ABAP/url-decoding.abap
Normal file
12
Task/URL-decoding/ABAP/url-decoding.abap
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
REPORT Z_DECODE_URL.
|
||||
|
||||
DATA: lv_encoded_url TYPE string VALUE 'http%3A%2F%2Ffoo%20bar%2F',
|
||||
lv_decoded_url TYPE string.
|
||||
|
||||
CALL METHOD CL_HTTP_UTILITY=>UNESCAPE_URL
|
||||
EXPORTING
|
||||
ESCAPED = lv_encoded_url
|
||||
RECEIVING
|
||||
UNESCAPED = lv_decoded_url.
|
||||
|
||||
WRITE: 'Encoded URL: ', lv_encoded_url, /, 'Decoded URL: ', lv_decoded_url.
|
||||
1
Task/URL-decoding/AppleScript/url-decoding.applescript
Normal file
1
Task/URL-decoding/AppleScript/url-decoding.applescript
Normal file
|
|
@ -0,0 +1 @@
|
|||
AST URL decode "google.com/search?q=%60Abdu%27l-Bah%C3%A1"
|
||||
|
|
@ -31,7 +31,7 @@ int decode(const char *s, char *dec)
|
|||
int main()
|
||||
{
|
||||
const char *url = "http%3A%2F%2ffoo+bar%2fabcd";
|
||||
char out[sizeof(url)];
|
||||
char out[strlen(url) + 1];
|
||||
|
||||
printf("length: %d\n", decode(url, 0));
|
||||
puts(decode(url, out) < 0 ? "bad string" : out);
|
||||
|
|
|
|||
2
Task/URL-decoding/Elixir/url-decoding.elixir
Normal file
2
Task/URL-decoding/Elixir/url-decoding.elixir
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
IO.inspect URI.decode("http%3A%2F%2Ffoo%20bar%2F")
|
||||
IO.inspect URI.decode("google.com/search?q=%60Abdu%27l-Bah%C3%A1")
|
||||
|
|
@ -1,16 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const escaped = "http%3A%2F%2Ffoo%20bar%2F"
|
||||
|
||||
func main() {
|
||||
if u, err := url.QueryUnescape(escaped); err == nil {
|
||||
fmt.Println(u)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
for _, escaped := range []string{
|
||||
"http%3A%2F%2Ffoo%20bar%2F",
|
||||
"google.com/search?q=%60Abdu%27l-Bah%C3%A1",
|
||||
} {
|
||||
u, err := url.QueryUnescape(escaped)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
fmt.Println(u)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
require'strings convert'
|
||||
urldecode=: rplc&(;"_1&a."2(,:tolower)'%',.hfd i.#a.)
|
||||
urldecode=: rplc&(~.,/;"_1&a."2(,:tolower)'%',.toupper hfd i.#a.)
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
urldecode=: rplc&(~.,/;"_1&a."2(,:tolower)'%',.hfd i.#a.)
|
||||
urldecode 'google.com/search?q=%60Abdu%27l-Bah%C3%A1'
|
||||
google.com/search?q=`Abdu'l-Bahá
|
||||
|
|
|
|||
7
Task/URL-decoding/Julia/url-decoding.julia
Normal file
7
Task/URL-decoding/Julia/url-decoding.julia
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
using URIParser
|
||||
|
||||
enc = "http%3A%2F%2Ffoo%20bar%2F"
|
||||
|
||||
dcd = unescape(enc)
|
||||
|
||||
println(enc, " => ", dcd)
|
||||
8
Task/URL-decoding/Oberon-2/url-decoding.oberon-2
Normal file
8
Task/URL-decoding/Oberon-2/url-decoding.oberon-2
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
MODULE URLDecoding;
|
||||
IMPORT
|
||||
URI := URI:String,
|
||||
Out := NPCT:Console;
|
||||
BEGIN
|
||||
Out.String(URI.Unescape("http%3A%2F%2Ffoo%20bar%2F"));Out.Ln;
|
||||
Out.String(URI.Unescape("google.com/search?q=%60Abdu%27l-Bah%C3%A1"));Out.Ln;
|
||||
END URLDecoding.
|
||||
3
Task/URL-decoding/Objective-C/url-decoding-2.m
Normal file
3
Task/URL-decoding/Objective-C/url-decoding-2.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
NSString *encoded = @"http%3A%2F%2Ffoo%20bar%2F";
|
||||
NSString *normal = [encoded stringByRemovingPercentEncoding];
|
||||
NSLog(@"%@", normal);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*REXX pgm convert an URL─encoded string ──► its original unencoded form*/
|
||||
url.1 = 'http%3A%2F%2Ffoo%20bar%2F'
|
||||
url.2 = 'mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
|
||||
url.3 = '%6D%61%69%6C%74%6F%3A%22%49%72%6D%61%20%55%73%65%72%22%20%3C%69%72%6D%61%2E%75%73%65%72%40%6D%61%69%6C%2E%63%6F%6D%3E'
|
||||
/*REXX program converts an URL─encoded string ──► its original unencoded form.*/
|
||||
url.1='http%3A%2F%2Ffoo%20bar%2F'
|
||||
url.2='mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
|
||||
url.3='%6D%61%69%6C%74%6F%3A%22%49%72%6D%61%20%55%73%65%72%22%20%3C%69%72%6D%61%2E%75%73%65%72%40%6D%61%69%6C%2E%63%6F%6D%3E'
|
||||
URLs=3
|
||||
do j=1 for URLs
|
||||
say url.j
|
||||
|
|
@ -9,7 +9,7 @@ URLs=3
|
|||
say
|
||||
end /*j*/
|
||||
exit
|
||||
/*──────────────────────────────────DECODEURL subroutine────────────────*/
|
||||
/*────────────────────────────────────────────────────────────────────────────*/
|
||||
decodeURL: procedure; parse arg encoded; decoded=''
|
||||
encoded=translate(encoded,,'+') /*special case for encoded blank.*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
/*REXX pgm convert an URL─encoded string ──► its original unencoded form*/
|
||||
url.1 = 'http%3A%2F%2Ffoo%20bar%2F'
|
||||
url.2 = 'mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
|
||||
url.3 = '%6D%61%69%6C%74%6F%3A%22%49%72%6D%61%20%55%73%65%72%22%20%3C%69%72%6D%61%2E%75%73%65%72%40%6D%61%69%6C%2E%63%6F%6D%3E'
|
||||
/*REXX program converts an URL─encoded string ──► its original unencoded form.*/
|
||||
url.1='http%3A%2F%2Ffoo%20bar%2F'
|
||||
url.2='mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
|
||||
url.3='%6D%61%69%6C%74%6F%3A%22%49%72%6D%61%20%55%73%65%72%22%20%3C%69%72%6D%61%2E%75%73%65%72%40%6D%61%69%6C%2E%63%6F%6D%3E'
|
||||
URLs=3
|
||||
do j=1 for URLs; say
|
||||
say url.j
|
||||
say URLdecode(url.j)
|
||||
do j=1 for URLs; say /*process each URL; display blank line.*/
|
||||
say url.j /*display the original URL. */
|
||||
say URLdecode(url.j) /* " " decoded " */
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────URLDECODE subroutine────────────────*/
|
||||
URLdecode: procedure; parse arg yyy /*get encoded URL from arg list. */
|
||||
yyy=translate(yyy,,'+') /*special case for encoded blank.*/
|
||||
URL=''
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*────────────────────────────────────────────────────────────────────────────*/
|
||||
URLdecode: procedure; parse arg yyy /*get encoded URL from argument list. */
|
||||
yyy=translate(yyy,,'+') /*a special case for an encoded blank. */
|
||||
URL=
|
||||
do until yyy=''
|
||||
parse var yyy plain '%' +1 code +2 yyy
|
||||
URL=URL || plain
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue