print u'\u2013' error on console/terminal

robert nospam at invalid.invalid
Thu Jun 25 06:05:58 EDT 2009


 >>> sys.stdout.encoding
'cp850'
 >>> print u'\u2013'
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
  0: character maps to <undefined>
 >>> sys.stdout.encoding='xy'
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' :

 >>> print u'a \2013 b'.encode('cp850','replace')
a ?3 b
 >>>


or a new filter file class necessary?



More information about the Python-list mailing list