On 2015-12-03, Adam Funk wrote: > I'm having trouble with some input files that are almost all proper > UTF-8 but with a couple of troublesome characters mixed in, which I'd > like to ignore instead of throwing ValueError. I've found the > openhook for the encoding > > for line in fileinput.input(options.files, > openhook=fileinput.hook_encoded("utf-8")): > do_stuff(line) > > which the documentation describes as "a hook which opens each file > with codecs.open(), using the given encoding to read the file", but > I'd like codecs.open() to also have the errors='ignore' or > errors='replace' effect. Is it possible to do this?
I forgot to mention: this is for Python 2.7.3 & 2.7.10 (on different machines). -- ...the reason why so many professional artists drink a lot is not necessarily very much to do with the artistic temperament, etc. It is simply that they can afford to, because they can normally take a large part of a day off to deal with the ravages. --- Amis _On Drink_ -- https://mail.python.org/mailman/listinfo/python-list