I'm using python 2.7
I have a file that contains hex strings:
\x01\x02\x93AAA
\x02\x02\x93AAA
\x03\x02\x93AAA
....
They are a mix of unprintable characters, represented as hex, and printablecharacters represented in ascii.
I am reading them into a map based on their line number. Then trying to send it over a socket. I am receiving inconsistent results when I send from my map versus as a straight string.
Example code:
print mymap[0]
mysocket.sendall(mymap[0])
mysocket.sendall("\x01\x02\x93AAA")
With these two send attempts, in wireshark, I can see the first one when sending from mymap is being sent in ASCII. As in it sends '\', 'x', '0', '1' instead of interpreting that as a hex 0x01. Where as the second line sends it correctly as hex data.
The print mymap[0] prints exactly the same string ("\x01\x02\x93AAA"), so why is one sending it as ASCII, and one sending it as hex?
I want it to send as hex, but when using my map It keeps sending it as ASCII, yet just hardcoding a string in sends as hex. Help?
Edit: I updated the title of this question to reflect what the underlying problem actually was. For those happening upon this later. My original thought was it had to do with reading the data from a map, when in reality the issue was reading it in from a file.