Skip to content

Instantly share code, notes, and snippets.

View izabera's full-sized avatar

Isabella Bosia izabera

  • DDN
  • Flitwick, UK
View GitHub Profile
@izabera
izabera / gist:ad1947357a96e51a8559
Last active August 29, 2015 14:26 — forked from geirha/gist:887e74e74877c7613920
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
local LC_ALL=C c i n IFS=
if (( (n = ${#1}) > 30 )); then
printf %s "$1" |
while read -rN1 c; do
if [[ $c = [[:alnum:].~_-] ]]; then printf %s "$c"
else printf %%%02X "'$c"
fi
done