I wrote:
> The other thing I'm not super pleased about is invoking
> pg_get_encoding_from_locale() each time through. That seems like a
> moderately expensive operation. I also wonder whether the result
> can change intra-run and whether gettext will track it if so.
Thinking about that some more: why don't we just drop that test,
along with the OUTPUT_CHARSET hacks, and confine ourselves to
testing that (1) server_encoding equals client_encoding and
(2) the translated string passes pg_encoding_verifymbstr?
Doing that is sufficient to guarantee that the translated label
will not fail the server's encoding check, and it depends only
on behaviors that are under our control; no guessing about what
gettext will do is required. It might be that the results will
look like junk to a human inspecting the server log later, but
I doubt we could make strong promises about that anyway.
regards, tom lane