Display a String as Integers

Created by CecilWesterhof.

Sometimes you have a string with unprintable characters and you like to know what those characters are. For this I wrote the following function:

proc displayStringAsInts {string} {
    foreach c [split $string ""] {
        set char [scan $c %c]
        puts [format "%4d | %c" $char $char]
    }
}

When calling it like:

displayStringAsInts "…¢€≠±¥"

This gives:

8230 | …
 162 | ¢
8364 | €
8800 | ≠
 177 | ±
 165 | ¥

As always: comments, tips, questions and request are appreciated.

See also