Skip to content

Instantly share code, notes, and snippets.

View MattL920's full-sized avatar

mattl920@gmail.com MattL920

View GitHub Profile
@MattL920
MattL920 / gist:6c991c14accdd974f4ea5f444cc08995
Created May 2, 2016 13:27 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;