title: Decoding double encoded utf8 in Python
body: <p>I've got a problem with strings that I get from one of my clients over xmlrpc. He sends me utf8 strings that are encoded twice :( so when I get them in python I have an unicode object that has to be decoded one more time, but obviously python doesn't allow that. I've noticed my client however I need to do quick workaround for now before he fixes it.</p>
  
  <p>Raw string from tcp dump: </p>
  
  <pre><code>&lt;string&gt;Rafa\xc3\x85\xc2\x82&lt;/string&gt;
  </code></pre>
  
  <p>this is converted into:</p>
  
  <pre><code>u'Rafa\xc5\x82'
  </code></pre>
  
  <p>The best we get is:</p>
  
  <pre><code>eval(repr(u'Rafa\xc5\x82')[1:]).decode("utf8") 
  </code></pre>
  
  <p>This results in correct string which is:</p>
  
  <pre><code>u'Rafa\u0142' 
  </code></pre>
  
  <p>this works however is ugly as hell and cannot be used in production code.
  If anyone knows how to fix this problem in more suitable way please write.
  Thanks,
  Chris</p>