urlencode
??????????? URL ???????,??? URL ??????????
? Linux ???,????? urlencode
?????????????????? URL ?????????????:
- ??
urlencode
?????(????):
#!/bin/bash input_string="Hello, World! ??,??!" encoded_string=$(urlencode "$input_string") echo "Encoded string: $encoded_string"
- ?? Bash ???? URL ??:
#!/bin/bash function urlencode() { local length="${#1}" for (( i = 0; i< length; i++ )); do local c="${1:$i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; *) printf '%%X' "'$c" ;; esac done } input_string="Hello, World! ??,??!" encoded_string=$(urlencode "$input_string") echo "Encoded string: $encoded_string"
??????????? urlencode
???,??????????????,??? URL ??????????,??????????????????,???????????
???,???????? Bash ?????????? shell(? zsh?fish ?),?????????