Handle more encodings.

Fixes #638