Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -31,3 +31,4 @@ However, this is an optional feature and is not a requirement of this task.
|
|||
|
||||
;See also
|
||||
[[URL decoding]]
|
||||
[[URL parser]]
|
||||
|
|
|
|||
1
Task/URL-encoding/AppleScript/url-encoding.applescript
Normal file
1
Task/URL-encoding/AppleScript/url-encoding.applescript
Normal file
|
|
@ -0,0 +1 @@
|
|||
AST URL encode "http://foo bar/"
|
||||
|
|
@ -5,7 +5,7 @@ char rfc3986[256] = {0};
|
|||
char html5[256] = {0};
|
||||
|
||||
/* caller responsible for memory */
|
||||
void encode(unsigned char *s, char *enc, char *tb)
|
||||
void encode(const char *s, char *enc, char *tb)
|
||||
{
|
||||
for (; *s; s++) {
|
||||
if (tb[*s]) sprintf(enc, "%c", tb[*s]);
|
||||
|
|
@ -16,8 +16,8 @@ void encode(unsigned char *s, char *enc, char *tb)
|
|||
|
||||
int main()
|
||||
{
|
||||
unsigned char url[] = "http://foo bar/";
|
||||
char enc[sizeof(url) * 3];
|
||||
const char url[] = "http://foo bar/";
|
||||
char enc[(strlen(url) * 3) + 1];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
|
|
|
|||
2
Task/URL-encoding/Elixir/url-encoding.elixir
Normal file
2
Task/URL-encoding/Elixir/url-encoding.elixir
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
iex(1)> URI.encode("http://foo bar/", &(URI.char_unreserved?/1))
|
||||
"http%3A%2F%2Ffoo%20bar%2F"
|
||||
3
Task/URL-encoding/Groovy/url-encoding.groovy
Normal file
3
Task/URL-encoding/Groovy/url-encoding.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def normal = "http://foo bar/"
|
||||
def encoded = URLEncoder.encode(normal, "utf-8")
|
||||
println encoded
|
||||
6
Task/URL-encoding/Julia/url-encoding.julia
Normal file
6
Task/URL-encoding/Julia/url-encoding.julia
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
using URIParser
|
||||
|
||||
dcd = "http://foo bar/"
|
||||
enc = escape(dcd)
|
||||
|
||||
println(dcd, " => ", enc)
|
||||
12
Task/URL-encoding/Oberon-2/url-encoding.oberon-2
Normal file
12
Task/URL-encoding/Oberon-2/url-encoding.oberon-2
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
MODULE URLEncoding;
|
||||
IMPORT
|
||||
Out := NPCT:Console,
|
||||
ADT:StringBuffer,
|
||||
URI := URI:String;
|
||||
VAR
|
||||
encodedUrl: StringBuffer.StringBuffer;
|
||||
BEGIN
|
||||
encodedUrl := NEW(StringBuffer.StringBuffer,512);
|
||||
URI.AppendEscaped("http://foo bar/","",encodedUrl);
|
||||
Out.String(encodedUrl.ToString());Out.Ln
|
||||
END URLEncoding.
|
||||
3
Task/URL-encoding/Objective-C/url-encoding-2.m
Normal file
3
Task/URL-encoding/Objective-C/url-encoding-2.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
NSString *normal = @"http://foo bar/";
|
||||
NSString *encoded = [normal stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
|
||||
NSLog(@"%@", encoded);
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
my $url = 'http://foo bar/';
|
||||
|
||||
say $url.subst(/<-[ A..Z a..z 0..9 ]>/, *.ord.fmt("%%%02X"), :g);
|
||||
say $url.subst(/<-alnum>/, *.ord.fmt("%%%02X"), :g);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue