Firstly, I appreciate any help you're willing to provide, so thanks for taking the time to read this. Also, I'm using python 3, but I'll do my best to convert any python 2 syntax for my needs.
I have managed to read my binary file to produce a very long string. Here's a small piece of it:
myfile = "\xde\xad\xbe\xef\x01\x00\xe1\x07\x01\x00\x01\x00\x1e\x00\"
I am trying to convert this to ASCII text. The first thing I'm struggling with is the backslashes. I have tried the following:
convert1 = myfile.split('\\\')
print(convert1)
This gives me:
['xde', 'xad', 'xbe', 'xef', 'x01', 'x00', 'xe1', 'x07', 'x01', 'x00', 'x01', 'x00']
The problem is I've lost my backslashes. I would like to have it output:
['\xde', '\xad', '\xbe', '\xef', '\x01', '\x00', '\xe1', '\x07', '\x01', '\x00', '\x01', '\x00']
From here I intend on using a for loop to convert each item in the list to an ordinal, and then later back to a character:
convert2 = []
for items in convert1:
i = ord(items)
convert2.append(i)
convert3 = []
for items in convert2:
i = chr(items)
convert3.append(i)
I hope this will give me the ASCII characters, but if you know an easier way, I'd love to hear it. Thanks in advance for your help.