2008/11/19 Decheng Fan <[EMAIL PROTECTED]>: > Hi, > > Recently I encountered a problem with the str.encode() function. I used the > function like this: s.encode("mbcs", "replace"), expecting it will eliminate > all invalid characters. However it failed with the following message: > UnicodeEncodeError: 'gbk' codec can't encode character '\ue104' in position > 4: i > > Am I using it in a wrong way or is it a bug?
print() sends it's data to stdout which encodes the data based on it's own encoding. If you want to change this behavior, replace sys.stdout with your own io.TextIOWrapper with 'replace' as the errors argument. -- Cheers, Benjamin Peterson "There's nothing quite as beautiful as an oboe... except a chicken stuck in a vacuum cleaner." _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com