Skip to content

Add new braille character table and color schemes #247

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aticu
Copy link

@aticu aticu commented Apr 21, 2025

When looking at hexdumps, I frequently find myself wishing for easier ways to distinguish between the different bytes that are just specified as . in a normal hexdump. I previously experimented with using the Unicode Braille characters for that. When I tried hexyl, I was immediately captured by the idea to add color and thought that color gradients would also add ways to distinguish between different bytes. I thought an image would say more than a thousand words, so I just went ahead and implemented this instead of opening an issue first. I hope this is fine for you.

Without further ado, here is what all bytes would look like with the --character-table braille --color-scheme gradient options after this PR is merged:

all bytes hexdump

I made several design decisions when implementing this:

  1. Setting the colors and the character set are two separate command line options. (Though they go well together, so I will not distinguish specifically between them here. Which option does what is hopefully obvious.)
  2. While different bytes should have different colors, there should still be different classes of bytes, so there are several gradients used.
  3. The colors should roughly get "hotter" as the byte values increase.
  4. 0x7f should not be in the same class as the other ASCII-non-printable characters as it has a very different numerical value. Picking this color was difficult, since it had to somehow fit into the general region but still be different enough so as not to be easily confusable.
  5. likely makes more sense in the category of printable ASCII than non-printable ASCII, since it's very likely to be frequently contained in normal text.
  6. 0x00, \t, \n and \r are not really printable charaters, but still important enough to have their own symbols.
  7. All other non-printable character are represented using Braille characters corresponding to their bits.

Here are some further examples to hopefully showcase how this can help pattern recognition:

UTF8:
UTF8 hexdump

UTF16LE with BOM:
UTF16LE with BOM hexdump

Randomness:
randomness hexdump

$MFT entry:
$MFT entry hexdump

hexyl binary (start):
hexyl binary hexdump

Unresolved question: How should this interact with the --print-color-table option? Currently this option ignores the color scheme. One option would be to show a smaller variant of the gradients with just 3-4 colors there.

Let me if you think anything should be adjusted.

EDIT: Added different character for tabs and changed 0x7f color.

@aticu
Copy link
Author

aticu commented Apr 21, 2025

The test failure seems unrelated? If not I am unsure how to proceed here and would be grateful for pointers.

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

Successfully merging this pull request may close these issues.

1 participant