# printable -- Replaces all unprintable characters into dots.
#
proc printable {s {spaces 0}} {
- regsub -all {[^\x09\x20-\x7e]} $s "." n
+ variable printable
+ if {![info exists printable]} {
+ for {set n 0} {$n < 256} {incr n} {
+ if {($n < 32 || $n >= 0x7e) && $n != 9} {
+ lappend printable [format %c $n] "."
+ }
+ }
+ }
+ set s [string map $printable $s]
if {$spaces} {
- regsub -all { } $n "_" n
+ set s [string map {" " "_"} $s]
}
- return $n;
+ return $s
}
##+##########################################################################
#