mirror of
https://github.com/mr0xb/scripts.git
synced 2026-08-27 19:34:57 -04:00
.
This commit is contained in:
parent
62156a1d85
commit
e698f046c8
5 changed files with 183 additions and 0 deletions
17
util/urle
Executable file
17
util/urle
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/env bash
|
||||
|
||||
urlencode_single_printf () {
|
||||
string=$1; format=; set --
|
||||
while [ -n "$string" ]; do
|
||||
tail=${string#?}
|
||||
head=${string%$tail}
|
||||
case $head in
|
||||
[-._~0-9A-Za-z]) format=$format%c; set -- "$@" "$head";;
|
||||
*) format=$format%%%02x; set -- "$@" "'$head";;
|
||||
esac
|
||||
string=$tail
|
||||
done
|
||||
printf "$format\\n" "$@"
|
||||
}
|
||||
|
||||
urlencode_single_printf $1
|
||||
Loading…
Reference in a new issue