Display a String as Integers

Difference between version 2 and 3 - Previous - Next
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 **

   * [Escaping special characters]
   * `dumpstr` in [Adding breakpoints to TkCon's internal debugger (idebug)]
   * `ftclp` in [ycl]

<<categories>>String Processing | Utilities