title: How to make the python interpreter correctly handle non-ASCII characters in string operations?
body: <p>I have a string that looks like so:</p>
  
  <pre><code>6Â 918Â 417Â 712
  </code></pre>
  
  <p>The clear cut way to trim this string (as I understand Python) is simply to say the string is in a variable called <code>s</code>, we get:</p>
  
  <pre><code>s.replace('Â ', '')
  </code></pre>
  
  <p>That should do the trick. But of course it complains that the non-ASCII character <code>'\xc2'</code> in file blabla.py is not encoded.</p>
  
  <p>I never quite could understand how to switch between different encodings.</p>
  
  <p>Here's the code, it really is just the same as above, but now it's in context. The file is saved as UTF-8 in notepad and has the following header:</p>
  
  <pre><code>#!/usr/bin/python2.4
  # -*- coding: utf-8 -*-
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>f = urllib.urlopen(url)
  
  soup = BeautifulSoup(f)
  
  s = soup.find('div', {'id':'main_count'})
  
  #making a print 's' here goes well. it shows 6Â 918Â 417Â 712
  
  s.replace('Â ','')
  
  save_main_count(s)
  </code></pre>
  
  <p>It gets no further than <code>s.replace</code>...</p>