Handle LookupErrors in repository encoding along with UnicodeError.

If the encoding field for a repository has garbage entries, or a system is
missing the locale information, trying to decode given a specific encoding
might fail with LookupError. In this case, we want to just continue through
with the rest of the logic.

Testing done: Ran unit tests.

Fixes bug 3399.