title: How to search and replace utf-8 special characters in Python?
body: <p>I'm a Python beginner, and I have a utf-8 problem.</p>
  
  <p>I have a utf-8 string and I would like to replace all german umlauts with ASCII replacements (in German, u-umlaut 'ü' may be rewritten as 'ue'). </p>
  
  <p>u-umlaut has unicode code point 252, so I tried this:</p>
  
  <pre><code>&gt;&gt;&gt; str = unichr(252) + 'ber'
  &gt;&gt;&gt; print repr(str)
  u'\xfcber'
  &gt;&gt;&gt; print repr(str).replace(unichr(252), 'ue')
  u'\xfcber'
  </code></pre>
  
  <p>I expected the last string to be <code>u'ueber'</code>.</p>
  
  <p>What I ultimately want to do is replace all u-umlauts in a file with 'ue':</p>
  
  <pre><code>import sys
  import codecs      
  f = codecs.open(sys.argv[1],encoding='utf-8')
  for line in f: 
      print repr(line).replace(unichr(252), 'ue')
  </code></pre>
  
  <p>Thanks for your help! (I'm using Python 2.3.)</p>