Version 2 of a little code page browser

Updated 2003-02-21 09:32:59

Richard Suchenwirth - The little tool below lets you select an encoding in the listbox and display the characters between \x00 and \xFF of that encoding, hence it is most suited for single-byte encodings. Especially useful for checking the various cp... code pages.

http://mini.net/files/codepages.jpg


 package require Tk
 listbox   .lb -yscrollcommand ".y set" -width 16
 bind .lb <Double-1> {showCodepage .t [selection get]}
 scrollbar .y -command ".lb yview"
 text .t -bg white -height 32 -wrap word
 pack .lb .y .t -side left -fill y
 pack .t        -fill both -expand 1

 foreach encoding [lsort [encoding names]] {
    .lb insert end $encoding
 }
 proc showCodepage {w encoding} {
    $w delete 1.0 end
    wm title . $encoding
    set hexdigits [list 0 1 2 3 4 5 6 7 8 9 A B C D E F]
    foreach high $hexdigits {
        foreach low $hexdigits {
            set c [encoding convertfrom $encoding [subst \\x$high$low]] 
            $w insert end "$high$low:$c "
        }
        $w insert end \n\n
    }
 } ;# RS

Arts and crafts of Tcl-Tk programming