proc subtagDecode {text} { set url "" regsub -all {\.([0-9a-fA-F][0-9a-fA-F])} $text {[format %c 0x\1]} text set text [subst $text] regsub -all "\r\n" $text "\n" text foreach byte [split [encoding convertto "utf-8" $text] ""] { scan $byte %c i if { $i < 33 } { append url [format %%%02X $i] } else { append url $byte } } return [string map {% .} $url] }