对于curl命令传入url中有中文返回空字符串无法正常使用的解决方法
一、原命令
area='河北'
orderId='order12321'
url="http://127.0.0.1:812/syx/process/$area/$orderId"
curl -X POST "$url"
二、解决方法
2.1安装xxd命令
sudo yum install vim-common
2.2 修改命令
转义中文字符串
area='河北'
orderId='order12321'
encoded_string=$(echo -n "$area" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
url="http://127.0.0.1:812/syx/process/$encoded_string/$orderId"
curl -X POST "$url"