07/10/2013, 11:17
(Modification du message : 07/10/2013, 16:37 par MenzAgitat.)
Voici le pendant de la fonction urlencode, bien que l'intérêt de son utilisation me semble très réduit.
Il s'agit d'une simple inversion du tableau présent dans la procédure.
source éditable
Il s'agit d'une simple inversion du tableau présent dans la procédure.
tcl
proc ::urldecode {data} {
return [::tcl::string::map {
"%20" " " "%22" "\"" "%23" "#" "%24" "$" "%25" "%"
"%26" "&" "%27" "'" "%28" "\(" "%29" "\)" "%2A" "*"
"%2B" "+" "%2C" "," "%2E" "." "%2F" "\/" "%3A" ":"
"%3B" ";" "%3C" "<" "%3D" "=" "%3E" ">" "%3F" "?"
"%40" "@" "%5B" "\[" "%5C" "\\" "%5D" "\]" "%5E" "^"
"%7B" "\{" "%7C" "|" "%7D" "\}" "%7E" "~" "%A1" "¡"
"%A2" "¢" "%A3" "£" "%A4" "¤" "%A5" "¥" "%A6" "¦"
"%A7" "§" "%A8" "¨" "%A9" "©" "%AA" "ª" "%AB" "«"
"%AC" "¬" "%AD" "" "%AE" "®" "%AF" "¯" "%B0" "°"
"%B1" "±" "%B2" "²" "%B3" "³" "%B4" "´" "%B5" "µ"
"%B6" "¶" "%B7" "·" "%B8" "¸" "%B9" "¹" "%BA" "º"
"%BB" "»" "%BC" "¼" "%BD" "½" "%BE" "¾" "%BF" "¿"
"%C0" "À" "%C1" "Á" "%C2" "Â" "%C3" "Ã" "%C4" "Ä"
"%C5" "Å" "%C6" "Æ" "%C7" "Ç" "%C8" "È" "%C9" "É"
"%CA" "Ê" "%CB" "Ë" "%CC" "Ì" "%CD" "Í" "%CE" "Î"
"%CF" "Ï" "%D0" "Ð" "%D1" "Ñ" "%D2" "Ò" "%D3" "Ó"
"%D4" "Ô" "%D5" "Õ" "%D6" "Ö" "%D7" "×" "%D8" "Ø"
"%D9" "Ù" "%DA" "Ú" "%DB" "Û" "%DC" "Ü" "%DD" "Ý"
"%DE" "Þ" "%DF" "ß" "%E0" "à" "%E1" "á" "%E2" "â"
"%E3" "ã" "%E4" "ä" "%E5" "å" "%E6" "æ" "%E7" "ç"
"%E8" "è" "%E9" "é" "%EA" "ê" "%EB" "ë" "%EC" "ì"
"%ED" "í" "%EE" "î" "%EF" "ï" "%F0" "ð" "%F1" "ñ"
"%F2" "ò" "%F3" "ó" "%F4" "ô" "%F5" "õ" "%F6" "ö"
"%F7" "÷" "%F8" "ø" "%F9" "ù" "%FA" "ú" "%FB" "û"
"%FC" "ü" "%FD" "ý" "%FE" "þ" "%FF" "ÿ"
} $data]
}
source éditable