string - Decoding double encoded utf8 in Python -
I have a problem with strings that I get from one of my clients on xmlrpc, it sends me utf8 string which is twice Are encoded: (So when I take them in python, I have a Unicode object which is to be decoded once, but obviously the dragon does not allow it. I have seen my client though the raw string from TCP dump:
& lt; string & gt; Rafa \ x C3 \ x85 \ xc2 \ x82
It is converted to:
We do get the best: eval (repr (u'Rafa \ xc5 \ x82 '); u'Rafa \ xc5 \ x82'
) [1:]). Decode ("utf8")
This result is in the correct string:
u'Rafa \ u0142 '
This work is ugly in the form of hell and can not be used in the production code. If someone knows how to fix this problem more correctly please write. Thanks, Chris
>>> s = U 'rafa \ xc5 \ x82' >>> SNX ('raw_incode_speep'). Decode ('UTF-8') U 'Rafa \ u0142' >>>
Comments
Post a Comment