Whack number two. I *think* I've implemented URI decoding, with
Juerd's help. I don't know how my hackish code will manage with
various flavours of UTF (especially wide characters) but I'll leave
that until it proves to be a problem. This works with my install of
pugs. I still have some TODOs, if anyone wants to have a go...
#!/usr/bin/pugs
print "content-type: text/html\n\n";
my %q = ();
my @q = split '&', %ENV.{'QUERY_STRING'};
for (@q) {
my ($n, $v) = split '=', $_;
#TODO: handle multiple values and same key
%q.{decode($n)} = decode($v);
}
for (%q.keys) { say $_, " => ", %q.{$_}, "<br>"; }
sub decode($input is rw) {
#TODO: handle wide characters?
$input ~~ s:Perl5:g/\+/ /;
$input ~~ s:Perl5:g/%(..)/{chr(:16["0x$0"])}/;
return $input;
}
--michael