You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
422 B
27 lines
422 B
#!/usr/bin/env bash |
|
|
|
##Helper Functions |
|
|
|
urlencodespecial() { |
|
# 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" ;; |
|
*) printf '%%%02X' "'$c" ;; |
|
esac |
|
done |
|
LC_COLLATE=$old_lc_collate |
|
} |
|
|
|
string="$1" |
|
if [ -z "$string" ]; then |
|
string="$(cat)" |
|
fi |
|
|
|
#URL |
|
urlencodespecial "$string" |
|
|
|
|