Fixe for UnsupportedCharsetException

This is a pull request for issue #508 as posted by @BalusC.

A test is included.