UrlEncode:
echo '你好中國' | tr -d '\n' | xxd -plain | sed 's/\(..\)/%\1/g' #echo '你好中國' |tr -d '\n' |od -An -tx1|tr ' ' %
輸出:%e4%bd%a0%e5%a5%bd%e4%b8%ad%e5%9b%bd
對輸入數據進行十六進制的轉換,並在每個轉換結果前面加上%(一般urlencode會在到后台服務器的時候,自動解碼)
UrlDecode:
printf $(echo -n "%e4%bd%a0%e5%a5%bd%e4%b8%ad%e5%9b%bd" | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"
輸出:你好中國
轉載請注明出處:https://www.cnblogs.com/fnlingnzb-learner/p/13064885.html