added support for different encodings