Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -31,3 +31,4 @@ However, this is an optional feature and is not a requirement of this task.
;See also
[[URL decoding]]
[[URL parser]]

View file

@ -0,0 +1 @@
AST URL encode "http://foo bar/"

View file

@ -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++) {

View file

@ -0,0 +1,2 @@
iex(1)> URI.encode("http://foo bar/", &(URI.char_unreserved?/1))
"http%3A%2F%2Ffoo%20bar%2F"

View file

@ -0,0 +1,3 @@
def normal = "http://foo bar/"
def encoded = URLEncoder.encode(normal, "utf-8")
println encoded

View file

@ -0,0 +1,6 @@
using URIParser
dcd = "http://foo bar/"
enc = escape(dcd)
println(dcd, " => ", enc)

View 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.

View file

@ -0,0 +1,3 @@
NSString *normal = @"http://foo bar/";
NSString *encoded = [normal stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSLog(@"%@", encoded);

View file

@ -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);