@Override
    public byte[] fromConnectData(String topic, Headers headers, Schema schema, Object value) {
        String encoding = extractEncoding(headers);

        try {
            return ((String) value).getBytes(encoding);
        } catch (UnsupportedEncodingException e) {
            throw new DataException("Unsupported encoding: " + encoding, e);
        }
    }
This is a simple Converter implementation that uses "encoding" header to encode/decode strings via provided charset name
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/SampleConverterWithHeaders.java