Messages : 2,338
Sujets : 191
Inscription : Apr 2004
11/11/2013, 11:19
(Modification du message : 12/11/2013, 12:25 par CrazyCat.)
Je ne crois pas avoir diffusé le bout de code inspiré de ça qui permet d'avoir l'encode et le decode:
tcl
set entities {
"à" "\\à" "à" "\\à" "á" "\\á" "â" "\\â"
"ã" "\\ã" "ä" "\\ä" "å" "\\å" "æ" "\\æ"
"ç" "\\ç" "è" "\\è" "é" "\\é" "ê" "\\ê"
"ë" "\\ë" "ì" "\\ì" "í" "\\í" "î" "\\î"
"ï" "\\ï" "ð" "\\ð" "ñ" "\\ñ" "ò" "\\ò"
"ó" "\\ó" "ô" "\\ô" "õ" "\\õ" "ö" "\\ö"
"÷" "\\÷" "ø" "\\ø" "ù" "\\ù" "ú" "\\ú"
"û" "\\û" "ü" "\\ü" "ý" "\\ý" "þ" "\\þ"
"ÿ" "\\ÿ" "\"" "\\"" "\\&" "\\&" "€" "\\€"
"œ" "\\œ" "Ÿ" "\\Ÿ" "¡" "\\¡"
"¢" "\\¢" "£" "\\£" "¤" "\\¤" "¥" "\\¥"
"¦" "\\¦" "¦" "\\&brkbar;" "§" "\\§" "¨" "\\¨"
"¨" "\\¨" "" "\\©" "ª" "\\ª" "«" "\\«"
"¬" "\\¬" "-" "\\& #8209;" "" "\\®" "¯" "\\¯"
"¯" "\\&hibar;" "°" "\\°" "±" "\\±" "²" "\\²"
"³" "\\³" "´" "\\´" "µ" "\\µ" "¶" "\\¶"
"·" "\\·" "¸" "\\¸" "¹" "\\¹" "º" "\\º"
"»" "\\»" "¼" "\\¼" "½" "\\½" "¾" "\\¾"
"¿" "\\¿" "À" "\\À" "Á" "\\Á" "Â" "\\Â"
"Ã" "\\Ã" "Ä" "\\Ä" "Å" "\\Å" "Æ" "\\Æ"
"Ç" "\\Ç" "È" "\\È" "É" "\\É" "Ê" "\\Ê"
"Ë" "\\Ë" "Ì" "\\Ì" "Í" "\\Í" "Î" "\\Î"
"Ï" "\\Ï" "Ð" "\\Ð" "Ð" "\\Đ" "Ñ" "\\Ñ"
"Ò" "\\Ò" "Ó" "\\Ó" "Ô" "\\Ô" "Õ" "\\Õ"
"Ö" "\\Ö" "×" "\\×" "Ø" "\\Ø" "Ù" "\\Ù"
"Ú" "\\Ú" "Û" "\\Û" "Ü" "\\Ü" "Ý" "\\Ý"
"Þ" "\\Þ" "ß" "\\ß" "\n" " " "\'" "\\'"
"&" "\\& #38;" "/" "\\& #047;" "\\" "\\& #092;" "\[" "\\& #091;"
"<" "\\<" ">" "\\>" "\]" "\\& #093"
"\(" "\\& #040;" "\)" "\\& #041;" "£" "\\& #163;"
"¨" "\\& #168;" "" "\\& #169;" "«" "\\& #171;" "" "\\& #173;"
"" "\\& #174;" "´" "\\& #180;" "·" "\\& #183;" "¹" "\\& #185;"
"»" "\\& #187;" "¼" "\\& #188;" "½" "\\& #189;" "¾" "\\& #190;"
"À" "\\& #192;" "Á" "\\& #193;" "Â" "\\& #194;" "Ã" "\\& #195;"
"Ä" "\\& #196;" "Å" "\\& #197;" "Æ" "\\& #198;" "Ç" "\\& #199;"
"È" "\\& #200;" "É" "\\& #201;" "Ê" "\\& #202;" "Ë" "\\& #203;"
"Ì" "\\& #204;" "Í" "\\& #205;" "Î" "\\& #206;" "Ï" "\\& #207;"
"Ð" "\\& #208;" "Ñ" "\\& #209;" "Ò" "\\& #210;" "Ó" "\\& #211;"
"Ô" "\\& #212;" "Õ" "\\& #213;" "Ö" "\\& #214;" "×" "\\& #215;"
"Ø" "\\& #216;" "Ù" "\\& #217;" "Ú" "\\& #218;" "Û" "\\& #219;"
"Ü" "\\& #220;" "Ý" "\\& #221;" "Þ" "\\& #222;" "ß" "\\& #223;"
"à" "\\& #224;" "á" "\\& #225;" "â" "\\& #226;" "ã" "\\& #227;"
"ä" "\\& #228;" "å" "\\& #229;" "æ" "\\& #230;" "ç" "\\& #231;"
"è" "\\& #232;" "é" "\\& #233;" "ê" "\\& #234;" "ë" "\\& #235;"
"ì" "\\& #236;" "í" "\\& #237;" "î" "\\& #238;" "ï" "\\& #239;"
"ð" "\\& #240;" "ñ" "\\& #241;" "ò" "\\& #242;" "ó" "\\& #243;"
"ô" "\\& #244;" "õ" "\\& #245;" "ö" "\\& #246;" "÷" "\\& #247;"
"ø" "\\& #248;" "ù" "\\& #249;" "ú" "\\& #250;" "û" "\\& #251;"
"ü" "\\& #252;" "ý" "\\& #253;" "þ" "\\& #254;"
}
proc htmlentities_encode {data} {
return [::tcl::string::map $::entities $data]
}
proc htmlentities_decode {data} {
return [::tcl::string::map [lreverse $::entities] $data]
}