urldecode plugin for gedit
For my friend Kenneth:
- Enable the “External Tools” plugin in the gedit plugin prefs click “Configure Plugin”
- Create a new plugin and name it UrlEncode
- Select a shortcut key
- Set Input & Output to Current selection / Replace current selection
Paste this into command(s):
#!/bin/sh
(C) 2006 GPL by Huidae Cho
awk '
BEGIN{
for(i = 0; i < 10; i++)
hex[i] = i
hex["A"] = hex["a"] = 10
hex["B"] = hex["b"] = 11
hex["C"] = hex["c"] = 12
hex["D"] = hex["d"] = 13
hex["E"] = hex["e"] = 14
hex["F"] = hex["f"] = 15
}
{
gsub(/\+/, " ")
i = $0
while(match(i, /%../)){
if(RSTART > 1)
printf "%s", substr(i, 1, RSTART-1)
printf "%c", hex[substr(i, RSTART+1, 1)] * 16 + hex[substr(i, RSTART+2, 1)]
i = substr(i, RSTART+RLENGTH)
}
print i
}
'
Further reading:
blog comments powered by Disqus