Make _hexdump behave more like "hexdump -C"

This commit is contained in:
dgelessus 2017-07-14 14:36:48 +02:00
parent c207703c9f
commit 5dbec5d905
2 changed files with 7 additions and 2 deletions

View File

@ -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
`````````````

View File

@ -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):