Skip to content

Feature request: Binary string diffing support #298

Closed

Description

@gschlager

Problem

When comparing binary strings (ASCII-8BIT encoding), super_diff shows unreadable output with escape sequences and control characters. This is common when testing file formats, network protocols, or any binary data.

Proposed solution

Add built-in support for binary string diffing that:

  1. Detects binary strings - Strings with Encoding::ASCII_8BIT
  2. Displays as hex dump - Shows offset, hex bytes, and printable ASCII:
    00000000: 7573 7461 7220 2000 0000 0000 0000 0000  ustar  .........                                                                                                                                         
    00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................                                                                                                                                         
    
  3. Shows context around changes - Only displays a few lines around actual differences (similar to unified diff)
  4. Inspects cleanly - Shows <binary string (512 bytes)> instead of garbled text

Working implementation

We have a working extension in mini_tarball that we'd be happy to contribute as a PR. It includes:

  • Differs::BinaryString
  • InspectionTreeBuilders::BinaryString
  • OperationTreeBuilders::BinaryString
  • OperationTrees::BinaryString
  • OperationTreeFlatteners::BinaryString

The implementation follows super_diff's architecture and has been working well for us when testing tar archive generation.

Would you be interested in a PR for this feature?

Activity

  1. jas14 commented on Feb 2, 2026

    @jas14
    Collaborator

    Hi @gschlager , thanks for the suggestion!

    I like this style of output, but this would be a big change from how binary strings are currently displayed. To avoid breaking people's expectations too much, I'd accept a PR to add this as an opt-in feature.

    I took a quick look at your code and see you're doing something similar to a lesser-known feature of SuperDiff called diff elision. Would you be able to incorporate this into your PR? (Though I'm not sure if it will work with multi-line strings as currently written.)

  2. added 3 commits that reference this issue on Feb 5, 2026
    5377c02
    d248ac3
    9e152d6
  3. gschlager commented on Feb 5, 2026

    @gschlager
    ContributorAuthor

    Thanks for the tip regarding diff elision. I created #300 and #301 which should solve this.

  4. jas14 commented on May 1, 2026

    @jas14
    Collaborator

    Implemented in #301 and released in v0.19.0 (today)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions