How can I encode and decode percent-encoded (URL encoded) strings on the command line?
I'm looking for a solution that can do this:
$ percent-encode "ændrük"
%C3%A6ndr%C3%BCk
$ percent-decode "%C3%A6ndr%C3%BCk"
ændrük
|
How can I encode and decode percent-encoded (URL encoded) strings on the command line? I'm looking for a solution that can do this:
|
||||
|
These commands do what you want:
If you want to encode spaces as I'm guessing you will want to alias them ;-) |
||||
|
|
|
Using PHP you can try the following command:
or just:
Use |
|||
|
|
|
I found a package, Unfortunately, it does not decode stdin or a command line option, but only rename a file, so you have to create a dummy file to obtain the decoding (the name of the renamed file), but with some bash scripting the process can be automated. No information about the encoding part, even because it could be questionable which characters to encode. Only non-ASCII? I think there should be some better tool/method. |
|||
|
|
%E6ndr%FCkdoesn't look like (standard) UTF8 to me. Or it's just an example? – arrange Jul 19 '11 at 21:13