Implement (a rough version of) escape schemes.

Escape schemes are a somewhat cleaner way of supporting the difference
between C-style and shell-style escaping than the previous hashmap
special case.

This is very rough at the moment (just look at the doctest examples!),
and will probably be tidied up.