[Richard Suchenwirth] 2005-10-21 - As work required me to modify [encoding]s, I needed a way to visualize what I had done. The following code works for one-byte encodings, which is all I need, and creates a 16x16 table on a [canvas], filling each with the glyph and the hexadecimal Unicode of one of the 256 code points in a given encoding. [http://mini.net/files/iso8859-6.jpg] For convenience, a "screen shot" is also taken and written as JPEG image in the current directory (this requires the [Img] extension). package require Tk package require Img pack [canvas .c -width 700 -height 700 -background white] set hex 0 for {set i 30} {$i<700} {incr i 40} { .c create line $i 30 $i 670 .c create line 30 $i 670 $i if {$hex < 16} { .c create text [expr $i+20] 15 -text [format %02X $hex] .c create text 15 [expr $i+20] -text [format %01X0 $hex] incr hex } } set encoding [lindex $argv 0] .c create text 30 680 -text "Encoding: $encoding" -anchor w set font {Courier 16 bold} for {set row 0} {$row < 16} {incr row} { for {set col 0} {$col < 16} {incr col} { set i [expr $row*16+$col] set c [encoding convertfrom $encoding [format %c $i]] .c create text [expr $col*40+50] [expr $row*40+44] -text $c -font $font set unicode [format %04X [scan $c %c]] .c create text [expr $col*40+50] [expr $row*40+62] -text $unicode } } #-- produce screenshot as GIF image after 500 { image create photo im1 -data .c im1 write $encoding.jpg -format JPEG } [VK] 21-oct-2005 Way good... following comments: you promise 'GIF' but do 'JPEG'; also, instead of last block 'after 500', why not to be a button: pack [button .b -text {produce screenshot as GIF image} -command { image create photo im1 -data .c im1 write $encoding.jpg -format JPEG }] ---- [Category Characters] | [Arts and crafts of Tcl-Tk programming]