Added support for non-unicode encodings.