title: UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-20: ordinal not in range(128)
body: <p>I got this error while writing to a file like this:
      <code>f.write(str(data))</code>
  and the problem was I was calling str on some data that contained Unicode characters and the default "ascii" encoder does not know how to encode them to bytes. This I understand.</p>
  
  <p>Then I did <code>print unicode(data)[13:20]</code> to see the offending characters and I could not see anything. Is there a way to detect that ? Thanks.</p>
  
  <p>Based on Steven Kryskala's suggestion I did <code>print repr(unicode(data))[13:21]</code> and got this:</p>
  
  <pre><code>u'\n&lt;body s'
  </code></pre>
  
  <p>Whats bad about that ?</p>