
namespace eval url {}
proc url::decodeQuery {query} {
   set result {}
   foreach pair [split $query "&"] {
      foreach {name value} [split $pair "="] {
 	 lappend result [decode $name] [decode $value]
      }
   }
   return $result
}

proc url::decode {data} {
   regsub -all {\+} $data " " data
   regsub -all {([][$\\])} $data {\\\1} data
   regsub -all {%([0-9a-fA-F][0-9a-fA-F])} $data  {[format %c 0x\1]} data
   return [subst $data]
}    

