Version 1 of Inspecting Unicode characters

Updated 2002-12-02 09:56:16

Arjen Markus (2 december 2002) I was looking for the Unicode of "promille" (0/00) and I got curious about the Unicode table itself. So, the following little script shows (a part of) that table. Nothing fancy - beyond the support for Unicode - but it might be useful.


 # unicode.tcl -- 
 #    Inspect the available characters for a part of the UNICODE table
 #

 package require Tktable

 # fillArray --
 #    Fill the array with unicode characters
 #
 # Arguments:
 #    array    Name of the array
 #    norows   Number of rows (number of columns is fixed to 16)
 #
 # Result:
 #    None
 #
 # Side effect:
 #    The array is filled with unicode characters: 0 to 16*norows-1
 #
 proc fillArray {array norows} {
    upvar $array chars

    set nocols  16
    for { set col 0 } { $col < $nocols } { incr col } {
       set code [format "%x" $col]
       set chars(0,$col) $code
    }
    set unicode  0
    for { set row 1 } { $row <= $norows } { incr row } {
       set code [format "%x" $unicode]
       set chars($row,0) $code
       for { set col 1 } { $col <= $nocols } { incr col } {
          set code [format "%x" $unicode]
          set chars($row,$col) [subst \\u$code]
          incr unicode
       }
    }
 }

 # showArray -- 
 #    Show the table
 #
 # Arguments:
 #    w        Widget that will contain the table
 #    array    Name of the array
 #    norows   Number of rows
 #
 # Result:
 #    None
 #
 # Side effect:
 #    The array is shown
 #
 proc showArray {w array norows} {
    if { $w == "." } {
       set t .table
       set x .xscroll
       set y .yscroll
    } else {
       set t $w.table
       set x $w.xscroll
       set y $w.yscroll
    }
    table $t -rows $norows -cols 16 \
       -colwidth 6 \
       -height   10 \
       -titlerows 1 -titlecols 1 -variable ::$array \
       -xscrollcommand "$x set" \
       -yscrollcommand "$y set"
    scrollbar $x -orient horizontal \
       -command "$t xview"
    scrollbar $y -orient vertical \
       -command "$t yview"
    grid $t $y
    grid $x  x

    grid $t   -sticky news
    grid $x   -sticky ew
    grid $y   -sticky ns

 }

 # main --
 #   Set up the main screen and fill it
 #

 global unicode_array

 fillArray unicode_array 100 
 showArray . unicode_array 100

Arts and crafts of Tcl-Tk programming

Category Characters