Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 10, 2014 10:47
Show Gist options
  • Select an option

  • Save coderofsalvation/8349984 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8349984 to your computer and use it in GitHub Desktop.
decodes an urlencoded string (%20 to ' ' e.g.)
# decodes an urlencoded string (%20 to ' ' e.g.)
# @param string input
# usage: echo "http://foo.com/foo.php$(urldecode "?foo=bar bar")"
urldecode(){
data="$(cat - | sed 's/+/ /g')"
printf '%b' "${data//%/\x}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment