Python: UnicodeEncodeError when printing accented characters
<p>Using Python 2.7.11</p>

<pre><code>#!/usr/bin/python
# -*- coding: utf-8 -*-
print 'ÃÃÅÃÅ'
print u'ÃÃÃÃÅ'
</code></pre>

<p>With the following result:</p>

<pre><code>âÃ¼âÃ«â¼ÃâÂ£â¼Ã
    Traceback (most recent call last):
        File "C:\Users\RaseR\Desktop\testing.py", line 4, in &lt;module&gt;
            print u'âÃ¼âÃ«âÃ»âÂ£â¼Ã'
        File "C:\Python27\lib\encodings\cp850.py", line 12, in encode
            return codecs.charmap_encode(input,errors,encoding_map)
    UnicodeEncodeError: 'charmap' codec can't encode character u'\u0150' in 
    position 4: character maps to &lt;undefined&gt;
</code></pre>

<p>If necessary:</p>

<p>Notepad++ with encoding UTF-8</p>

<p>Windows 10 Console w/ Lucida Console Font</p>

<p>When you <code>print</code>, you are printing to standard output. Standard output uses some encoding and everything has to be converted to that encoding.</p>

<p>In my case:</p>

<pre><code>&gt;&gt;&gt; sys.stdout.encoding
'cp852'
&gt;&gt;&gt; u'\u0150'.encode(sys.stdout.encoding)
'\x8a'
&gt;&gt;&gt; print u'\u0150'
Å
&gt;&gt;&gt; print '\x8a'
Å
</code></pre>

<p>In your case, it seems that the Å character does not exist in the encoding used by stdout, so the conversion fails. There is no way to print that.</p>

<p>You can encode it manually, specifying what to do with characters which cannot be encoded:</p>

<pre><code>&gt;&gt;&gt; print u'\u0150'.encode(sys.stdout.encoding, 'replace')
Å
</code></pre>

<p>With a character which it cannot encode:</p>

<pre><code>&gt;&gt;&gt; print u'\u0150\u1234'.encode(sys.stdout.encoding, 'replace')
Å?
</code></pre>

python unicode utf-8 decode encode