Created
January 8, 2013 21:39
-
-
Save rcknr/4488234 to your computer and use it in GitHub Desktop.
Simplistic URL encoding for Busybox shell.
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 characters
#!/bin/sh | |
echo "$@" | awk -v ORS="" '{ gsub(/./,"&\n") ; print }' | while read l; | |
do | |
case "$l" in | |
[-_.~a-zA-Z0-9] ) echo -n ${l} ;; | |
"" ) echo -n %20 ;; | |
* ) printf '%%%02X' "'$l" | |
esac | |
done | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment