之前写过一版 shell下解码url,下面给出另外一个版本

from https://gist.github.com/cdown/1163649

function urlencode() {
local LANG=C
for ((i=;i<${#};i++)); do
if [[ ${:$i:} =~ ^[a-zA-Z0-\.\~\_\-]$ ]]; then
printf "${1:$i:1}"
else
printf '%%%02X' "'${1:$i:1}"
fi
done
}
urldecode() {
# urldecode <string> local url_encoded="${1//+/ }"
printf '%b' "${url_encoded//%/\\x}"
}

好用就行

05-28 04:33