Request to merge character set specification changes

Hello, further to my comment on issue #27, I've had a crack at merging the changes you started to make in the fix branch into the current master.

As part of merging, I've taken the liberty of simplifying some of the logic, mostly by adding a `*charset*` dynamic var rather than trying to thread it as as parameter all through the code. Hope that looks OK to you.

Cheers,

Matthew.