Improve escape-characters performance.

This no longer performs a large number of generic dispatches.

This also only now supports writing <byte-string> as <unicode-string>
isn't yet supported correctly.