forked from hummypkg/webif
020e1b707c
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@933 2a923420-c742-0410-a762-8d5b09965624
31 lines
582 B
Plaintext
31 lines
582 B
Plaintext
package require binary
|
|
|
|
proc hexdump {str} {
|
|
set s ""
|
|
set addr 0
|
|
|
|
append s "[format "%07x" $addr]: "
|
|
set t ""
|
|
for {set i 0} {$i < [string length $str]} {incr i} {
|
|
if {$i > 0 && [expr $i % 16] == 0} {
|
|
append s " $t\n"
|
|
append s "[format "%07x" $addr]: "
|
|
incr addr 16
|
|
set t ""
|
|
} elseif {$i > 0 && [expr $i % 2] == 0} {
|
|
append s " "
|
|
}
|
|
|
|
set char [string index $str $i]
|
|
binary scan $char H2 cc
|
|
append s $cc
|
|
if {[string is print $char]} {
|
|
append t $char
|
|
} else {
|
|
append t "."
|
|
}
|
|
}
|
|
puts $s
|
|
}
|
|
|