-
-
Save CodeShane/c51afc417b8d0e24b53c1ee015cec354 to your computer and use it in GitHub Desktop.
Revisions
-
cdown revised this gist
Feb 15, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ urlencode() { # urlencode <string> old_lc_collate=$LC_COLLATE LC_COLLATE=C local length="${#1}" for (( i = 0; i < length; i++ )); do @@ -12,7 +12,7 @@ urlencode() { esac done LC_COLLATE=$old_lc_collate } urldecode() { -
cdown revised this gist
Feb 15, 2016 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,7 @@ urlencode() { local c="${1:i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; *) printf '%%%02X' "'$c" ;; esac done -
cdown revised this gist
Feb 15, 2016 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ urlencode() { # urlencode <string> old_lc_all=$LC_ALL LC_ALL=C local length="${#1}" for (( i = 0; i < length; i++ )); do local c="${1:i:1}" @@ -10,6 +12,8 @@ urlencode() { while read c; do printf '%%%s' "$c"; done ;; esac done LC_ALL=$old_lc_all } urldecode() { -
cdown revised this gist
Oct 20, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ urlencode() { local c="${1:i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; *) printf '%s' "$c" | xxd -p -c1 | while read c; do printf '%%%s' "$c"; done ;; esac done -
cdown revised this gist
Jul 28, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,8 @@ urlencode() { local c="${1:i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; *) printf '%s' '$c' | xxd -p -c1 | while read c; do printf '%%%s' "$c"; done ;; esac done } -
cdown revised this gist
Jul 28, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,5 +15,5 @@ urldecode() { # urldecode <string> local url_encoded="${1//+/ }" printf '%b' "${url_encoded//%/\\x}" } -
cdown revised this gist
May 21, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,7 @@ urlencode() { local c="${1:i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; *) printf '%%%02X' "'$c" esac done } -
cdown revised this gist
Mar 3, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,9 @@ urlencode() { # urlencode <string> local length="${#1}" for (( i = 0; i < length; i++ )); do local c="${1:i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; ' ') printf + ;; *) printf '%%%X' "'$c" -
cdown revised this gist
Dec 18, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ urlencode() { # urlencode <string> local length="${#1}" for (( i = 0 ; i < length ; i++ )); do local c="${1:i:1}" case "$c" in -
cdown revised this gist
Dec 18, 2013 . 1 changed file with 20 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,21 @@ urlencode() { # urlencode <string> local length="${#1}" for (( i = 0 ; i < length ; i++ )); do local c="${1:i:1}" case "$c" in [a-zA-Z0-9.~_-]) printf "$c" ;; ' ') printf + ;; *) printf '%%%X' "'$c" esac done } urldecode() { # urldecode <string> local url_encoded="${1//+/ }" printf '%b' "${url_encoded//%/\x}" } -
cdown revised this gist
Oct 10, 2013 . No changes.There are no files selected for viewing
-
cdown revised this gist
Oct 10, 2013 . 1 changed file with 20 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,20 @@ urlencode() { # urlencode <string> local length="${#1}" for (( i = 0 ; i < length ; i++ )); do local c="${1:i:1}" case "$c" in [a-zA-Z0-9.~_-]) printf "$c" ;; ' ') printf + ;; *) printf '%%%X' "'$c" esac done } urldecode() { # urldecode <string> local url_encoded=${1//+/ } printf '%b' "${url_encoded//%/\x}" } -
Chris Down revised this gist
Aug 18, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ urldecode() { # Usage examples url='http://example.com/foo bar baz?fizz=buzz&wibble=wobble' printf 'Original URL: %s\n' "$url" printf 'Encoded URL: %s\n' "$(urlencode "$url")" printf 'Decoded URL: %s\n' "$(urldecode "$(urlencode "$url")")" -
Chris Down revised this gist
Aug 18, 2012 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ #!/bin/bash urlencode() { local l=${#1} for (( i = 0 ; i < l ; i++ )); do local c=${1:i:1} @@ -14,7 +13,12 @@ urlencode() { } urldecode() { local data=${1//+/ } printf '%b' "${data//%/\x}" } # Usage examples url='http://example.com/foo bar baz?fizz=buzz&wibble=wobble' printf 'Original URL: %s\n' "$url" printf 'Encoded URL: %s\n' "$(urlencode "$url")" printf 'Decoded URL: %s\n' "$(urldecode "$(urlencode "$url")")" -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,9 @@ urlencode() { # Usage: urlencode string local l=${#1} for (( i = 0 ; i < l ; i++ )); do local c=${1:i:1} case "$c" in [a-zA-Z0-9.~_-]) printf "$c" ;; ' ') printf + ;; @@ -15,6 +15,6 @@ urlencode() { urldecode() { # Usage: urldecode string local data=${1//+/ } printf '%b' "${data//%/\x}" } -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,5 +16,5 @@ urlencode() { urldecode() { # Usage: urldecode string data=${1//+/ } printf '%b' "${data//%/\x}" } -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,11 +4,11 @@ urlencode() { # Usage: urlencode string local l="${#1}" for (( i = 0 ; i < l ; i++ )); do c=${1:i:1} case "$c" in [a-zA-Z0-9.~_-]) printf "$c" ;; ' ') printf + ;; *) printf '%%%X' "'$c" esac done } -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,5 +15,6 @@ urlencode() { urldecode() { # Usage: urldecode string data=${1//+/ } printf '%b' "${data//\%/\x}" } -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash urlencode() { # Usage: urlencode string local l="${#1}" for (( i = 0 ; i < l ; i++ )); do offsetByte=${1:i:1} @@ -11,4 +11,9 @@ urlencode() { *) printf '%%%X' "'$offsetByte" esac done } urldecode() { # Usage: urldecode string printf '%b' "${1//\%/\x}" } -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash urlencode() { # Usage: urlencode url local l="${#1}" for (( i = 0 ; i < l ; i++ )); do offsetByte=${1:i:1} -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ #!/bin/bash encode() { # Usage: encode $url local l="${#1}" for (( i = 0 ; i < l ; i++ )); do offsetByte=${1:i:1} -
Chris Down revised this gist
Aug 16, 2012 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,15 @@ #!/bin/bash encode() { # Usage: encode 'http://foo.bar/baz?wibble=wobble&fizz=buzz' local l="${#1}" for (( i = 0 ; i < l ; i++ )); do offsetByte=${1:i:1} case "$offsetByte" in [a-zA-Z0-9.~_-]) printf "$offsetByte" ;; ' ') printf + ;; *) printf '%%%X' "'$offsetByte" esac done } -
Chris Down revised this gist
May 22, 2012 . 1 changed file with 10 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,13 @@ #!/bin/bash encode() { local len="${#1}" for (( i = 0 ; i < len ; i++ )); do offsetByte="${1:i:1}" case "${offsetByte}" in [a-zA-Z0-9.~_-]) printf "${offsetByte}" ;; ' ') printf + ;; *) printf '%%%X' "'${offsetByte}" esac done } -
Chris Down revised this gist
Aug 22, 2011 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,7 @@ _encode() { *) printf '%%%X' "'${_print_offset}" ;; esac done } _url='http://google.com' _url_encoded=$(_encode "${_url}") -
Chris Down created this gist
Aug 22, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ _encode() { local _length="${#1}" for (( _offset = 0 ; _offset < _length ; _offset++ )); do _print_offset="${1:_offset:1}" case "${_print_offset}" in [a-zA-Z0-9.~_-]) printf "${_print_offset}" ;; ' ') printf + ;; *) printf '%%%X' "'${_print_offset}" ;; esac done }