title: Python - Change string to utf8
body: <p>I am trying to write Portuguese to an HTML file but I am getting some funny characters.  How do I fix this?</p>
  
  <pre><code>first = """&lt;p style="color: red; font-family: 'Liberation Sans',sans-serif"&gt;{}&lt;/p&gt;""".format(sentences1[i]) 
  f.write(first)
  </code></pre>
  
  <p>Expected Output:
  Hoje, nós nos unimos ao povo...</p>
  
  <p>Actual Output in browser (Firefox on Ubuntu):
  ï»¿Hoje, nÃ³s nos unimos ao povo...</p>
  
  <p>I tried doing this:</p>
  
  <pre><code>first = """&lt;p style="color: red; font-family: 'Liberation Sans',sans-serif"&gt;{}&lt;/p&gt;""".format(sentences1[i]) 
  f.write(first.encode('utf8'))
  </code></pre>
  
  <p>Output in terminal:
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 65: ordinal not in range(128)</p>
  
  <p>Why am I getting this error and also how can I write other languages to an HTML doc without the funny characters?<br>
  Or, is there a different file type that I can write to with the above font formatting?</p>