I am using xmlrpc to send a string of characters (arbitrary 8-bit character) from a server to a client. As it turns out, the carriage-return character \r (dec 13 hex 0xd) gets suppressed. That is, when the original string consists of the following three characters (represented by their hex-code):
0x3a 0xd 0xa
then I receive on the client side only ‘two’ characters:
0x3a 0xa
How can I configure xmlrpc (in python) so I am able to receive the full, original 3-characters string with 0xd? Is there a way this can be done without using a binary wrapper or something else?
When you pass an str object as a string value in XML-RPC, it is encoded and decoded as a string. (BTW, that string should consist of characters allowed in XML, though that is not important in your case.) It is not a binary block, and
\r\nis translated to\nwhen XML is parsed. IMHO, nothing can be done, and no set of options saves the situation.Just see what
dumps()andloads()fromxmlrpclibdo to your string:So, when
loads()is performed, the\r\nsequence is translated to\n, and\ris lost. You may, of course, use a transformed string (e.g.s.encode('hex')looks quite nice), but, as far as I understand, if you can not alter server behavior (to performs.decode('hex')on the parameter), nothing can help.