title: Can't open Unicode URL with Python
body: <p>Using Python 2.5.2 and Linux Debian, I'm trying to get the content from a Spanish URL that contains a Spanish char <code>'í'</code>:</p>
  
  <pre><code>import urllib
  url = u'http://mydomain.es/índice.html'
  content = urllib.urlopen(url).read()
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 8: ordinal not in range(128)</p>
  </blockquote>
  
  <p>I've tried using before passing the url to urllib this:</p>
  
  <pre><code>url = urllib.quote(url)
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>url = url.encode('UTF-8')
  </code></pre>
  
  <p>but they didn't work.</p>
  
  <p>Can you tell me what I am doing wrong ?</p>