icecream icon indicating copy to clipboard operation
icecream copied to clipboard

Improve output for strings

Open Jakeroid opened this issue 3 months ago • 0 comments

Issue

Characters inside strings can modify their output by default. This leads to lost or misleading information when debugging.

Proposed Solution

Make IceCream output strings in a way that preserves all information by default. That means:

  • Showing control characters and invisibles explicitly instead of letting them affect terminal layout.
  • Deciding carefully whether newlines should render literally or as escaped symbols.

Examples

  1. Control characters alter the output instead of being visible. For instance, \b (backspace) removes characters → abc\bX prints as abX (information lost).
  2. Invisible Unicode characters disappear silently. For instance, Zero-width space (\u200B), left/right marks (\u200E, \u200F) are not shown → the user cannot tell they exist.
  3. Newlines are always shown as multi-line blocks. I’m not confident this should be the default behavior.
  4. Whitespace is ambiguous. For instance, tabs (\t) are expanded into spaces, making them indistinguishable.
  5. Long strings flood the output. Very long lines are printed in full without truncation or summary.
  6. Bytes / bytearray with control characters. For instance, bytes with \n or \x00 are printed raw, producing real line breaks or invisible content.

Open Questions

  1. Should escaped/visible mode be the default behavior?
  2. Should there be an option to output strings in a more readable form than one huge single line?
  3. Do we want to summarize long strings (length, line count, preview) instead of printing the full content by default?

Jakeroid avatar Sep 14 '25 10:09 Jakeroid