Capturing the bad codes that raise UnicodeError exceptions during decoding

Random832 random832 at fastmail.com
Thu Aug 4 15:45:24 EDT 2016


On Thu, Aug 4, 2016, at 15:22, Malcolm Greene wrote:
> Hi Chris,
> 
> Thanks for your suggestions. I would like to capture the specific bad
> codes *before* they get replaced. So if a line of text has 10 bad codes
> (each one raising UnicodeError), I would like to track each exception's
> bad code but still return a valid decode line when finished. 

Look into writing your own error handler - there's enough information
provided to do this.

https://docs.python.org/3/library/codecs.html



More information about the Python-list mailing list