mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-09 05:33:48 -05:00
function to decode HTML special characters
This commit is contained in:
@@ -514,9 +514,16 @@ progressBar() {
|
|||||||
tput cnorm
|
tput cnorm
|
||||||
}
|
}
|
||||||
|
|
||||||
# URL encoding/decoding from: https://gist.github.com/cdown/1163649
|
htmlDecode() {
|
||||||
|
# Decode HTML characters with sed
|
||||||
|
# Usage: htmlDecode <string>
|
||||||
|
echo "${1}" | sed -f "${SOURCEPATH}/htmlDecode.sed"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
urlencode() {
|
urlencode() {
|
||||||
# urlencode <string>
|
# URL encoding/decoding from: https://gist.github.com/cdown/1163649
|
||||||
|
# Usage: urlencode <string>
|
||||||
|
|
||||||
local length="${#1}"
|
local length="${#1}"
|
||||||
for (( i = 0; i < length; i++ )); do
|
for (( i = 0; i < length; i++ )); do
|
||||||
@@ -529,7 +536,7 @@ urlencode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
urldecode() {
|
urldecode() {
|
||||||
# urldecode <string>
|
# Usage: urldecode <string>
|
||||||
|
|
||||||
local url_encoded="${1//+/ }"
|
local url_encoded="${1//+/ }"
|
||||||
printf '%b' "${url_encoded//%/\x}"
|
printf '%b' "${url_encoded//%/\x}"
|
||||||
|
|||||||
Reference in New Issue
Block a user