Add `encoding()` and `deteted_encoding()`.

This allows formatters to output in the original encoding, should they wish.
The value of the detected or configured encoding is now also kept in the
output tree. Thanks to Patrice Dumas for the patch!