[buffer] Templatize UTF handling

Also move UTF routines into a separate file, to be reused from shapers
that need it.
3 files changed