Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created September 11, 2012 05:29
Show Gist options
  • Select an option

  • Save tjluoma/3696160 to your computer and use it in GitHub Desktop.

Select an option

Save tjluoma/3696160 to your computer and use it in GitHub Desktop.
This is a file meant to be used with 'sed' for url-encoding strings.
s:%:%25:g
s: :%20:g
s:<:%3C:g
s:>:%3E:g
s:#:%23:g
s:{:%7B:g
s:}:%7D:g
s:|:%7C:g
s:\\:%5C:g
s:\^:%5E:g
s:~:%7E:g
s:\[:%5B:g
s:\]:%5D:g
s:`:%60:g
s:;:%3B:g
s:/:%2F:g
s:?:%3F:g
s^:^%3A^g
s:@:%40:g
s:=:%3D:g
s:&:%26:g
s:\$:%24:g
s:\!:%21:g
s:\*:%2A:g
s:,:%2C:g
s:(:%28:g
s:):%29:g
@codelahoma
Copy link

If you have node installed, the following bash function is handy:

function urlencode { 
  node -e "console.log(encodeURIComponent('${*}'))"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment