print u'\u2013' error on console/terminal

R

robert

sys.stdout.encoding
'cp850'Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\Lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character
u'\u2013' in position
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: readonly attribute



is there a switch to suppress those encoding errors for standard
print's on the console - e.g. for getting automatic behavior like
'replace' :


or a new filter file class necessary?
 
M

Martin v. Löwis

is there a switch to suppress those encoding errors for standard print's
on the console

No, there is no such switch.
or a new filter file class necessary?

You can wrap sys.stdout with a codecs.StreamWriter, passing "replace"
as the error handler.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top