Prevent output of =encoding in most cases.

Add `keep_encoding_directive()` which is false by default, to prevent
formatters from emitting a document's `=encoding` directive in most cases.
That they emitted the encoding was a bug introduced in v3.26 (RT #84093). Now,
only the DumpAsText and DumpAsXML formats set it to true. Patch from Patrice
Dumas.