title: Reading a text file in unicode from a URL?
body: <p>I'm trying to use urllib and urllib2 to read from a text file that has french characters in it, like "é", "à", and so on. </p>
  
  <pre><code>def load(url):
       from urllib2 import Request, urlopen, URLError, HTTPError
  
       req = Request(url)
  
       f = urlopen(req)
       f.readline()
  
       for line in f:
            line = line.split('\t')
            word = line[0].encode('utf-8')
  </code></pre>
  
  <p>I have a feeling that the read() method returns me a byte string, so I use encode('utf-8') to get the unicode value, but this gives me the following error</p>
  
  <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 6: ordinal not in range(128)
  </code></pre>
  
  <p>Can someone tell me what's going on? Any help would be appreciated. Thanks!</p>