mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-04-25 07:52:58 -05:00
Merge pull request #267 from sepalani/utils
Utils: Do not print \r\n\t in hexdump
This commit is contained in:
commit
939c24d833
|
|
@ -275,19 +275,21 @@ def pretty_print_hex(orig_data, cols=16, sep=' '):
|
|||
"""
|
||||
data = bytearray(orig_data)
|
||||
end = len(data)
|
||||
line = "%08x | %-*s | %s\n"
|
||||
line = "\n%08x | %-*s | %s"
|
||||
size = cols * 3 - 1
|
||||
|
||||
i = 0
|
||||
output = ""
|
||||
while i < end:
|
||||
j = i + cols if i + cols <= end \
|
||||
else end - i
|
||||
if i + cols < end:
|
||||
j = i + cols
|
||||
else:
|
||||
j = end
|
||||
output += line % (
|
||||
i,
|
||||
size,
|
||||
sep.join("%02x" % c for c in data[i:j]),
|
||||
"".join(chr(c) if chr(c) in string.printable else
|
||||
"".join(chr(c) if 0x20 <= c < 0x7F else
|
||||
'.'
|
||||
for c in data[i:j])
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user