This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giampaolo.rodola
Recipients David.Sankel, Matt.Mackall, akira, amaury.forgeotdarc, brian.curtin, christian.heimes, christoph, davidsarah, ezio.melotti, giampaolo.rodola, hippietrail, lemburg, mark, mhammond, pitrou, santoso.wijaya, smerlin, ssbarnea, terry.reedy, tim.golden, tzot, v+python, vstinner
Date 2012-05-19.18:55:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1337453741.43.0.0339857115988.issue1602@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2012-05-19 18:55:41giampaolo.rodolasetrecipients: + giampaolo.rodola, lemburg, mhammond, terry.reedy, tzot, amaury.forgeotdarc, pitrou, vstinner, christian.heimes, tim.golden, mark, christoph, ezio.melotti, v+python, hippietrail, ssbarnea, brian.curtin, davidsarah, santoso.wijaya, akira, David.Sankel, smerlin, Matt.Mackall
2012-05-19 18:55:41giampaolo.rodolasetmessageid: <1337453741.43.0.0339857115988.issue1602@psf.upfronthosting.co.za>
2012-05-19 18:55:40giampaolo.rodolalinkissue1602 messages
2012-05-19 18:55:40giampaolo.rodolacreate