scripts/util/urle
Steve B e698f046c8 .
2025-12-05 14:53:37 -05:00

17 lines
No EOL
374 B
Shell
Executable file

#!/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