match spec tightly about which characters to encode, fixes #83, #46

This is much more straight-forward than the previous solution but maybe also a bit slower.