Communauté Eggdrop
[Astuce] url_encode en tcl - Version imprimable

+- Communauté Eggdrop (https://forum.eggdrop.fr)
+-- Forum : Eggdrop et TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=8)
+--- Forum : Scripts TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=4)
+--- Sujet : [Astuce] url_encode en tcl (/showthread.php?tid=444)



[Astuce] url_encode en tcl - CrazyCat - 01/07/2009

J'ai trouvé ceci suite à une question posée sur #eggdrops, c'est une procédure pour faire de l'url_encoding en tcl:
tcl
proc urlencode {text} {
    set url ""
    foreach byte [split [encoding convertto utf-8 $text] ""] {
        scan $byte %c i
        if {[string match {[%<>"]} $byte] || $i <= 32 || $i > 127} {
            append url [format %%%02X $i]
        } else {
            append url $byte
        }
    }
    return $url
}



La source est sur cette page, en espérant que ça servira.