From 5dbec5d9059d921a45417e8df554cca1351ba900 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Fri, 14 Jul 2017 14:36:48 +0200 Subject: [PATCH] Make _hexdump behave more like "hexdump -C" --- README.rst | 4 +++- rsrcfork.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5fe9fbb..835f44c 100644 --- a/README.rst +++ b/README.rst @@ -85,7 +85,8 @@ Command-line interface $ python3 -m rsrcfork /Users/Shared/Test.textClipping "'TEXT' (256)" Resource 'TEXT' (256), unnamed, no attributes, 17 bytes: 00000000 48 65 72 65 20 69 73 20 73 6f 6d 65 20 74 65 78 |Here is some tex| - 00000010 74 |t | + 00000010 74 |t| + 00000011 Limitations @@ -142,6 +143,7 @@ Version 1.1.1 ````````````` * Fixed overflow issue with empty resource files or empty resource type entries +* Changed ``_hexdump`` to behave more like ``hexdump -C`` Version 1.1.0 ````````````` diff --git a/rsrcfork.py b/rsrcfork.py index 3fc9be2..9279a2c 100644 --- a/rsrcfork.py +++ b/rsrcfork.py @@ -577,7 +577,10 @@ def _hexdump(data: bytes): line = data[i:i + 16] line_hex = " ".join(f"{byte:02x}" for byte in line) line_char = line.decode("MacRoman").translate(_TRANSLATE_NONPRINTABLES) - print(f"{i:08x} {line_hex:<{16*2+15}} |{line_char:<16}|") + print(f"{i:08x} {line_hex:<{16*2+15}} |{line_char}|") + + if data: + print(f"{len(data):08x}") def _raw_hexdump(data: bytes): for i in range(0, len(data), 16):