mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 22:32:47 +00:00
228290c0d1
python's %r. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113685 91177308-0d34-0410-b5e6-96231b3b80d8
14 lines
384 B
Python
14 lines
384 B
Python
def dataToHex(d):
|
|
""" Convert the raw data in 'd' to an hex string with a space every 4 bytes.
|
|
"""
|
|
bytes = []
|
|
for i,c in enumerate(d):
|
|
byte = ord(c)
|
|
hex_byte = hex(byte)[2:]
|
|
if byte <= 0xf:
|
|
hex_byte = '0' + hex_byte
|
|
if i % 4 == 3:
|
|
hex_byte += ' '
|
|
bytes.append(hex_byte)
|
|
return ''.join(bytes).strip()
|