data-out: Optimize and fix some bad assumptions.
Until now, data_out_pool() and its wrapper function data_out() have always
done at least two memory allocations: one to fill in the initial version
of the result and another to recode it to UTF-8. However, recoding to
UTF-8 is usually unnecessary, because most output formats always produce
output in UTF-8 anyway. Only binary formats and the string A format ever
produce data in other encodings, so this commit drops recoding entirely
except for those cases. Binary formats are a particularly special case:
usually it doesn't make any sense to use these formats for text output,
but this commit does its best to translate the binary output bytes into
valid UTF-8, at least up to the first null byte.
This commit also finishes fixing up display widths.
The closely related data_out_legacy() function, which only has one user
in three also needed some work. It was badly named, so I renamed it to
data_out_recode(). It made the bad assumption that the data passed in
was encoded in ASCII (written C_ENCODING). It also made the bad
assumption that the number of bytes output would be exactly the format's
width. This rewrite fixes these problems.