I'm not sure if the handling of the encoding parameters here and below is ideal now. This is rather a quick&dirty solution.