BEGIN{
  RS="&|\n";
  FS="=";
  x2d["0"]=0
  x2d["1"]=1
  x2d["2"]=2
  x2d["3"]=3
  x2d["4"]=4
  x2d["5"]=5
  x2d["6"]=6
  x2d["7"]=7
  x2d["8"]=8
  x2d["9"]=9
  x2d["a"]=10
  x2d["b"]=11
  x2d["c"]=12
  x2d["d"]=13
  x2d["e"]=14
  x2d["f"]=15
  x2d["A"]=10
  x2d["B"]=11
  x2d["C"]=12
  x2d["D"]=13
  x2d["E"]=14
  x2d["F"]=15
}

{
    if ($1 != "") {
        # Quote all parameters
        printf("%s=\"", $1);
        val = $2
        if (val ~ /%/) {
            valRemainder = val
            while (start = match(valRemainder, "%[0-9][0-9]")) {
                printf("%s", substr(valRemainder, 1, start - 1))
                hexNum = 16*(x2d[substr(valRemainder, start + 1, 1)]) + x2d[substr(valRemainder, start + 2, 1)]
                printf("%c", hexNum);
                valRemainder = substr(valRemainder, start + 3)
            }
            printf("%s", valRemainder);
        } else {
            printf("%s", val);
        }
        # Quote all parameters
        printf("\"\n");
    }
}
