I'm using awk
to urldecode some text.
If I code the string into the printf
statement like printf "%s", "\x3D"
it correctly outputs =
. The same if I have the whole escaped string as a variable.
However, if I only have the 3D
, how can I append the \x
so printf
will print the =
and not \x3D
?
I'm using busybox awk 1.4.2
and the ash
shell.
This relies on gnu awk's extension of the split function, but this works:
gawk '{ numElems = split($0, arr, /%../, seps);
outStr = ""
for (i = 1; i <= numElems - 1; i++) {
outStr = outStr arr[i]
outStr = outStr sprintf("%c", strtonum("0x" substr(seps[i],2)))
}
outStr = outStr arr[i]
print outStr
}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With