Simpler decoding

This fix is on top of #855; when I was debugging a failing test I noticed the `decode` method had some problems; in particular some of the optimization assumptions only hold for character encodings that are "backwards compatible" with ASCII (i.e. Latin-1, UTF-8).

The resulting code is simpler but I'm not sure if it affected performance.

Filed this as a separate pull request from #855 incase you decide only supporting Latin-1/UTF-8/ASCII is fine (whereas #855 is unambiguously a bug).