JSON printed to console shows wrong encoding
<p>I am trying to read Cyrillic characters from some JSON file and then output it to console using <strong>Python 3.4.3 on Windows</strong>. Normal print('Russian smth Ð±ÑÐºÐ²Ñ') works as intended.</p>

<p>But when I print JSON contents it seems to print in Windows-1251 - "Ð¡ÐÐ¡ÑÐ¡ÐÐ¡ÐÐ ÑÐ ÑÐ Âµ Ð Â±Ð¡ÑÐ ÑÐ ÐÐ¡â¹" (though my console, my JSON file and my .py (with coding comment) are in UTF-8).</p>

<p>I've tried re-encoding it to Win-1251 and setting console to Win-1251, but still no luck.</p>

<p><em>My JSON (Encoded in UTF-8):</em></p>

<pre><code>{
  "ÑÑÑÑÐºÐ¸Ðµ Ð±ÑÐºÐ²Ñ": "ÑÑÐ¾-ÑÐ¾ ÐµÑÑ Ð½Ð° ÑÑÑÑÐºÐ¾Ð¼",
  "english letters": "Ð¸ ÑÑÐ¾-ÑÐ¾ Ð½Ð° Ð²ÐµÐ»Ð¸ÐºÐ¾Ð¼"
}
</code></pre>

<p><em>My code to load dictionary:</em></p>

<pre><code>def load_dictionary():
global Dictionary, isFatal
try:
    with open(DictionaryName) as f:
        Dictionary = json.load(f)
except Exception as e:
    logging.critical('Error loading dictionary: ' + str(e))
    isFatal = True
    return
logging.info('Dictionary was loaded successfully')
</code></pre>

<p>I am trying to output it in 2 ways (both show the same gibberish):</p>

<pre><code>print(helper.Dictionary.get('rly'))
print(helper.Dictionary)
</code></pre>

<hr>

<p>An interesting add-on: I've added the whole Russian alphabet to my JSON file and it seems to <strong>get stuck at "Ð¡ Ñ" letter</strong>. <em>(Error loading dictionary: 'charmap' codec can't decode byte 0x81 in position X: character maps to )</em>. If I remove this one letter it shows no exception, but the problem above remains.</p>

<p>"<em>But when I print JSON contents â¦</em>" </p>

<p>If you print it using <code>type</code> command, then you get <a href="https://en.wikipedia.org/wiki/Mojibake" rel="nofollow">mojibake</a> <code>Ð¡ÐÐ¡ÑÐ¡ÐÐ¡ÐÐ ÑÐ ÑÐ Âµ â¦</code> instead of <code>ÑÑÑÑÐºÐ¸Ðµ â¦</code> under <code>CHCP 1251</code> scope. </p>

<p>Try <code>type</code> under <a href="http://ss64.com/nt/chcp.html" rel="nofollow"><code>CHCP 65001</code> (i.e. <code>UTF-8</code>)</a> scope.</p>

<p>Follow <a href="http://stackoverflow.com/questions/39755662/json-printed-to-console-shows-wrong-encoding?noredirect=1#comment66807809_39755662">nauer's advice</a>, use <code>open(DictionaryName, encoding="utf8")</code>.</p>

<p><strong>Example</strong> (<code>39755662.json</code> is saved with <code>UTF-8</code> encoding):</p>

<pre><code>==&gt; chcp 866
Active code page: 866

==&gt; type 39755662.json
{
  "â¤Ðâ¤Ðâ¤Ðâ¤Ðâ¨ââ¨ââ¨â¡ â¨ââ¤Ðâ¨ââ¨ââ¤Ð": "â¤Ðâ¤Ðâ¨â-â¤Ðâ¨â â¨â¡â¤Ðâ¤Ð¡ â¨ââ¨â â¤Ðâ¤Ðâ¤Ðâ¤Ðâ¨ââ¨ââ¨â",
  "rly": "â¤Ðâ¤Ðâ¤Ðâ¤Ðâ¨ââ¨ââ¨â£"
}

==&gt; chcp 1251
Active code page: 1251

==&gt; type 39755662.json
{
  "Ð¡ÐÐ¡ÑÐ¡ÐÐ¡ÐÐ ÑÐ ÑÐ Âµ Ð Â±Ð¡ÑÐ ÑÐ ÐÐ¡â¹": "Ð¡â¡Ð¡âÐ Ñ-Ð¡âÐ Ñ Ð ÂµÐ¡â°Ð¡â Ð ÐÐ Â° Ð¡ÐÐ¡ÑÐ¡ÐÐ¡ÐÐ ÑÐ ÑÐ Ñ",
  "rly": "Ð¡ÐÐ¡ÑÐ¡ÐÐ¡ÐÐ ÑÐ ÑÐ â"
}

==&gt; chcp 65001
Active code page: 65001

==&gt; type 39755662.json
{
  "ÑÑÑÑÐºÐ¸Ðµ Ð±ÑÐºÐ²Ñ": "ÑÑÐ¾-ÑÐ¾ ÐµÑÑ Ð½Ð° ÑÑÑÑÐºÐ¾Ð¼",
  "rly": "ÑÑÑÑÐºÐ¸Ð¹"
}

==&gt;
</code></pre>

python json python-3.x utf-8 cyrillic