PumpgunMessiah
Technical User
[ignore]I'm in the midst of writing a rather quick and dirty URL Encoding function (replacing all specials characters with their hex value, i.e. ' text.html' -> ' via AWK and am struggling on this rather simple task.[/ignore]
Well, it's rather easy achieving this by using printf via shell (notice the apostrophe in front of the ASCII character, in this case the [):
printf "%02x" "'["
> 5b
But I'm having trouble replicating the same effect with AWK. I've already tried everything with either the AWK internal printf or sprintf. But I'm not even sure if the apostrophe is necessary, which I also had trouble to concatenate to the character to be converted, since even 'escaped' via backslash I couldn't add the darn ' without errors. I've solved this in a rather ugly way by using 'awk -v' to bring the apostrophe from "outside" of awk.
But still, I can't get awk's printf function to do same as the "regular" shell printf.
Well, it's rather easy achieving this by using printf via shell (notice the apostrophe in front of the ASCII character, in this case the [):
printf "%02x" "'["
> 5b
But I'm having trouble replicating the same effect with AWK. I've already tried everything with either the AWK internal printf or sprintf. But I'm not even sure if the apostrophe is necessary, which I also had trouble to concatenate to the character to be converted, since even 'escaped' via backslash I couldn't add the darn ' without errors. I've solved this in a rather ugly way by using 'awk -v' to bring the apostrophe from "outside" of awk.
But still, I can't get awk's printf function to do same as the "regular" shell printf.