Closed gcmoreira closed 4 months ago
@atcuno
Thank you @gcmoreira! @ikelos the bug was obviously bad, but then only showing 8 per row was very unusual compared to every other common hex dump utilities and all GUI hex editors, which all show 16 across. Also, only showing 8 produces many extraneous lines in the terminal compared to 8 per row.
Missing bytes
On the one hand, this PR fixes an issue with the hexdump text render function
hex_bytes_as_text
. The previous implementation failed to handle buffer lengths that are not multiples of 8 bytes, resulting in missing bytes in its output.For instance, using the text
abcd
, the previous implementation didn't dump anything.On the contrary, the new implementation correctly handles this case.
Using a 22 bytes buffer
abcdefghijklmnopqrstuv
, the old implementation misses the lastqrstuv
bytes:While the new implementation handles this case too.
16 bytes width
On the other hand, this PR increases the hexdump width from 8 bytes to 16 bytes per row for better visualization and to match other hex dump tools/utilities.
Before:
After:
Lost in Space
Lastly, the new implementation includes the space character (0x20) in the list of printable characters which, for some reason, was omitted in the original version.