#! /usr/bin/awk -f # # decode "application/x-www-form-urlencoded" data # written by Yasha, public domain # BEGIN { # make hexadecimal table h["0"] = 0; h["1"] = 1; h["2"] = 2; h["3"] = 3; h["4"] = 4; h["5"] = 5; h["6"] = 6; h["7"] = 7; h["8"] = 8; h["9"] = 9; h["A"] = 10; h["B"] = 11; h["C"] = 12; h["D"] = 13; h["E"] = 14; h["F"] = 15; h["a"] = 10; h["b"] = 11; h["c"] = 12; h["d"] = 13; h["e"] = 14; h["f"] = 15; } /[+%]/ { for (i = 1; i <= length; i++) { c = substr($0, i, 1); if (c == "%") { c1 = substr($0, i+1, 1); c2 = substr($0, i+2, 1); printf "%c", h[c1] * 16 + h[c2]; i += 2; } else if (c == "+") { printf " " } else printf "%s", c } print ""; next } { print }