Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data::Printer doesn't escape control characters #184

Open
nrdvana opened this issue Aug 22, 2023 · 1 comment
Open

Data::Printer doesn't escape control characters #184

nrdvana opened this issue Aug 22, 2023 · 1 comment

Comments

@nrdvana
Copy link
Contributor

nrdvana commented Aug 22, 2023

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.

@nrdvana
Copy link
Contributor Author

nrdvana commented Sep 14, 2023

Bump. Maybe to ask in a less rambling way:

  • Do you agree that there should be an option to show nonprintable characters?
  • Do you agree that it should be enabled by default?
  • If so, should my patch expand the scope of print_escapes or should it be new options for the value of escape_chars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant