Added support for custom character encoding