docs: public void setEncoding(Encoding encoding) throws IOException {
      if (this.encoding != null && this.encoding.name().equals(encoding.name())) {
        return;
      }
      // Close down any old writer.
      if (encodingWriter != null) {
        encodingWriter.close();
      }
  
      this.encoding = encoding;
  
      // Intercept flush() downcalls from the writer; our caller
      // will call PGStream.flush() as needed.
      OutputStream interceptor = new FilterOutputStream(pgOutput) {
        public void flush() throws IOException {
        }
  
        public void close() throws IOException {
          super.flush();
        }
      };
  
      encodingWriter = encoding.getEncodingWriter(interceptor);
    }