ctrans.org

urlencode

Tcl版のurlencode*1

#urlencode
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
}

関連:Tcl - http manual page

関連:tcllib:ncgi

*1:例では文字コードをUTF-8としている

2006-06-20 15:58:26
permalink | Tcl/Tk

←PDIC用追加辞書ファイル | top | これまで使ったことのないタグ→

Post a Comment

HTMLタグは適用されません。不適切と判断されたコメントはブロックされます。

:

:

: