The purpose of Data::Printer is to show people what is in their data, but currently there is no way to see if a string contains [\x01-\x07\x0E-\x1F]. These are not escaped by escape_chars or by print_escapes. This might be my terminal, but I get no output at all from characters like "\x01" so there are essentially invisible to me when using Data::Printer.
I can propose a patch, but I thought I would discuss first. Data::Printer aims to have "sensible defaults", and its purpose is for debugging, so the thing that makes the most sense to me would be to always escape nonprintable characters which have no effect on the rendered output. For example, "\n" doesn't need escaped by default because you can see its effect on a terminal, even though it is technically not a printable character, but "\x7F" and maybe even ones like nonbreaking space "\xA0" and byte-order-mark "\xFEFF" ought to be escaped by default. I know it is definitely helpful to see BOMs as I use the escape_chars = nonascii, but users whose regular text fall into nonascii range probably don't turn that setting on.
It could be added as a new setting escape_chars = nonprintable? (and sure would be nice to have on by default)
Edit well that's not quite right either, because what I want is closer to escape_chars = nonprintable_and_nonascii. And leave escape_chars = nonprintable as an option for people who want to see the nonascii unicode in their output.
escape_chars = nonprintable would sort of make print_escapes obsolete, though, because print_escapes refers only to specific nonprintable control chars. Another option would be to expand print_escapes to include all nonprintable characters.
The purpose of Data::Printer is to show people what is in their data, but currently there is no way to see if a string contains
[\x01-\x07\x0E-\x1F]. These are not escaped byescape_charsor byprint_escapes. This might be my terminal, but I get no output at all from characters like"\x01"so there are essentially invisible to me when using Data::Printer.I can propose a patch, but I thought I would discuss first. Data::Printer aims to have "sensible defaults", and its purpose is for debugging, so the thing that makes the most sense to me would be to always escape nonprintable characters which have no effect on the rendered output. For example, "\n" doesn't need escaped by default because you can see its effect on a terminal, even though it is technically not a printable character, but
"\x7F"and maybe even ones like nonbreaking space"\xA0"and byte-order-mark"\xFEFF"ought to be escaped by default. I know it is definitely helpful to see BOMs as I use theescape_chars = nonascii, but users whose regular text fall into nonascii range probably don't turn that setting on.It could be added as a new setting
escape_chars = nonprintable? (and sure would be nice to have on by default)Edit well that's not quite right either, because what I want is closer to
escape_chars = nonprintable_and_nonascii. And leaveescape_chars = nonprintableas an option for people who want to see the nonascii unicode in their output.escape_chars = nonprintablewould sort of makeprint_escapesobsolete, though, becauseprint_escapesrefers only to specific nonprintable control chars. Another option would be to expandprint_escapesto include all nonprintable characters.