I am sending a fix message over socket connection and recieving within a python client. I know there is a SOH seperating each name=value pair in the data. But the data when printed(as a string), does not show the SOH. The problem arises because I want to be able to show the '|' or I cannot tell within a regular expression, what the boundaries for the individual fields are. I have looked at decode('hex'), decode('uu') on the recieved string , without much success. Also the pack/unpack require that you supply a format string(which I would have to do for every type of fix).
I am using the Twisted ClientFactory for the client.
Any suggestions?
Follow Up Question: I use the repr and pass it to a function to replace the '\x01' with '|'. Now when I pass in the data recieved from the network directly, replace seems to have no affect. However when I copy the output and pass it as a string literal into the same function. It behaves as expected(replaces '\x01' with '|'). I also tried using a re.sub, with exactly the same results( works when passed in as a string literal , but not when passed in directly from the network). I also printed the value from the network into a file , and compared using vi hex editor , to the string literal. It does not reveal any differences.
Some additional information: When I print the value from a file and read it back, I am not able to use find on '\x01', implying that replace would not work either(it does not). When I try to convert this into a byte array , it would appear that each of the '\' , 'x' , '0', '1' are interpreted as different bytes, when i iterate over the byte array. Which is strange. either the '\x01' is a string or its not and is hex.
Any suggestions?
thanks
It would appear that replace using '\x01' works on the data coming in over the network(and not the output of repr). I am not sure what the reason is, but this meets my requirement.