Version 4 of scan

Updated 2002-01-25 06:54:25

http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/scan.htm


display and numeric format for ASCII characters. display and numeric format for ASCII characters. Scan provides the usual answer:

    foreach character {a A b B c} {
        scan $character %c numeric
        puts "ASCII character '$numeric' displays as '$character'."
    }

    ASCII character '97' displays as 'a'.
    ASCII character '65' displays as 'A'.
    ASCII character '98' displays as 'b'.
    ASCII character '66' displays as 'B'.
    ASCII character '99' displays as 'c'.        

In more recent Tcl's (8.3 or so up) you also can call scan inline:

 set numeric [scan $character %c]. And the %c format is not limited to ASCII, but can handle any Unicode. ([RS])

Also see "Dump a file in hex and ASCII", as well as "u2x" in the "Bag of algorithms".

Effect on the Internal Representation of a Value


Tcl syntax help - Arts and crafts of Tcl-Tk programming - Category Command