Unicode error Python3 calendar module
Question: I'm trying to print a simple calendar from python `calendar` module:

    
    
    import calendar
    
    c = calendar.LocaleTextCalendar(0, 'Russian')
    s = c.formatmonth(2016, 5)
    print(s)
    

On linux it works well, but on Windows I got an error: `UnicodeEncodeError:
'charmap' codec can't encode characters in position 4-10: character maps to
<undefined>`

All I can do to avoid the error is `print(s.encode('ascii',
'replace').decode('ascii'))` (with locale text values missed), so I'm
intrested in common nice solution.

Thanks in advance.


Answer: That happens because the windows console encoding is not Unicode.
Unfortunately it is not trivial and there are several way to work around this.

What is the encoding of your console? You can find out in Python this way

    
    
    import sys
    sys.stdin.encoding
    

you can try to set Unicode this way only for the current console:

    
    
    chcp 65001
    python myScript.py
    

In your script make sure that your string is encoded into UTF-8.

