in reply to Displaying NUL in a TK::Text widget

NUL is not a printable character anyway. In binary file viewers (and editors) it is customary to replace all non-printable characters (ie 0x00 to 0x1f and 0x7f to 0xff) with a dot in the character display.
  • Comment on Re: Displaying NUL in a TK::Text widget

Replies are listed 'Best First'.
Re^2: Displaying NUL in a TK::Text widget
by thor (Priest) on Nov 08, 2004 at 13:43 UTC
    it is customary to replace all non-printable characters (ie 0x00 to 0x1f and 0x7f to 0xff) with a dot
    In this case, the non-printable characters have semantic meaning. I want to be able to tell the difference between chr(0) and chr(5).

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      So how about displaying ".foo." in the button and then when the user does a mouseover, display a tiny window with "\x00foo\x05" or whatever format is most appropriate for your environment?
      --traveler
      You need to then display the numerical values of those characters, such as 0x00, 0x05 and so on. You can't display a character with ASCII value 0x00, because there is no such printable character. Other control characters do weird things, so should never be printed, such as 0x07 (BEL) and 0x0C (FF). Trying to output data containing the special control characters can *really* screw things up.

      You might like to take a look at how such data is displayed by my module Data::Hexdumper. Don't look at the code though, it's old and nasty :-)

        That's the whole point. I wasn't explicit about it, but that's what's done by default for other "weird" characters" in the ASCII set. Try ASCII-6 (ACK) for instance. It would be nice if I could extend the same mechanism to include NUL.

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come