Handle invalid encodings (text charsets). Fixes #1.