Giampaolo Rodola' <g.rod...@gmail.com> added the comment:

Not sure whether a solution has already been proposed because the issue is very 
long, but I just bumped into this on Windows and come up with this:


from __future__ import print_function
import sys

def safe_print(s):
    try:
        print(s)
    except UnicodeEncodeError:
        if sys.version_info >= (3,):
            print(s.encode('utf8').decode(sys.stdout.encoding))
        else:
            print(s.encode('utf8'))

safe_print(u"\N{EM DASH}")


Couldn't python do the same thing internally?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1602>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to