@Override
    public void encode(Event event, OutputStream output) throws IOException {
        String outputString = (format == null
                ? JSON_MAPPER.writeValueAsString(event.getData())
                : StringInterpolation.evaluate(event, format))
                + delimiter;
        output.write(outputString.getBytes(charset));
    }
@Test
    public void testEncodeWithCharset() throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        byte[] rightSingleQuoteInUtf8 = {(byte) 0xE2, (byte) 0x80, (byte) 0x99};
        String rightSingleQuote = new String(rightSingleQuoteInUtf8, Charset.forName("UTF-8"));

        // encode with cp-1252
        Map<String, Object> config = new HashMap<>();
        config.put("charset", "cp1252");
        config.put("format", "%{message}");
        config.put("delimiter", "");
        Event e1 = new Event(Collections.singletonMap("message", rightSingleQuote));
        Line cp1252encoder = new Line(new ConfigurationImpl(config), new TestContext());
        byte[] rightSingleQuoteInCp1252 = {(byte) 0x92};

        cp1252encoder.encode(e1, outputStream);
        byte[] resultBytes = outputStream.toByteArray();
        Assert.assertArrayEquals(rightSingleQuoteInCp1252, resultBytes);
    }