title: Python ascii utf unicode
body: <p>When I parse this XML with <code>p = xml.parsers.expat.ParserCreate()</code>:</p>
  
  <pre><code>&lt;name&gt;Fortuna D&amp;#252;sseldorf&lt;/name&gt;
  </code></pre>
  
  <p>The character parsing event handler includes <code>u'\xfc'</code>.</p>
  
  <p>How can <code>u'\xfc'</code> be turned into <code>u'ü'</code>?</p>
  
  <hr>
  
  <p>This is the main question in this post, the rest just shows further (ranting) thoughts about it </p>
  
  <p>Isn't Python unicode broken since <code>u'\xfc'</code> shall yield <code>u'ü'</code> and nothing else?
  u'\xfc' is already a unicode string, so converting it to unicode again doesn't work!
  Converting it to ASCII as well doesn't work.</p>
  
  <p>The only thing that I found works is: (This cannot be intended, right?)</p>
  
  <pre><code>exec( 'print u\'' + 'Fortuna D\xfcsseldorf'.decode('8859') + u'\'')
  </code></pre>
  
  <p>Replacing 8859 with utf-8 fails! What is the point of that?</p>
  
  <p>Also what is the point of the Python unicode HOWTO? - it only gives examples of fails instead of showing how to do the conversions one (especially the houndreds of ppl who ask similar questions here) actually use in real world practice.</p>
  
  <p>Unicode is no magic - why do so many ppl here have issues?</p>
  
  <p>The underlying problem of unicode conversion is dirt simple:</p>
  
  <p>One bidirectional lookup table '\xFC' &lt;-> u'ü'</p>
  
  <pre><code>unicode( 'Fortuna D\xfcsseldorf' ) 
  </code></pre>
  
  <p>What is the reason why the creators of Python think it is better to show an error instead of simply producing this: <code>u'Fortuna Düsseldorf'</code>?</p>
  
  <p>Also why did they made it not reversible?:</p>
  
  <pre><code> &gt;&gt;&gt; u'Fortuna Düsseldorf'.encode('utf-8')
   'Fortuna D\xc3\xbcsseldorf'
   &gt;&gt;&gt; unicode('Fortuna D\xc3\xbcsseldorf','utf-8')
   u'Fortuna D\xfcsseldorf'    
  </code></pre>