title: Python: replace nonbreaking space in Unicode
body: <p>In Python, I have a text that is Unicode-encoded. This text contains non-breaking spaces, which I want to convert to 'x'. Non-breaking spaces are equal to <code>chr(160)</code>. I have the following code, which works great when I run it as Django via Eclipse using Localhost. No errors and any non-breaking spaces are converted.</p>
  
  <pre><code>my_text = u"hello"
  my_new_text = my_text.replace(chr(160), "x")
  </code></pre>
  
  <p>However when I run it any other way (Python command line, Django via runserver instead of Eclipse) I get an error:</p>
  
  <pre><code>'ascii' codec can't decode byte 0xa0 in position 0: ordinal not in range(128)
  </code></pre>
  
  <p>I guess this error makes sense because it's trying to compare Unicode (my_text) to something that isn't Unicode. My questions are:</p>
  
  <ol>
  <li>If <code>chr(160)</code> isn't Unicode, what is it?</li>
  <li>How come this works when I run it from Eclipse? Understanding this would help me determine if I need to change other parts of my code. I have been testing my code from Eclipse.</li>
  <li>(most important) How do I solve my original problem of removing the non-breaking spaces? <code>my_text</code> is definitely going to be Unicode.</li>
  </ol>