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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top