package org.pacey.dropwizardpebble;

import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.error.PebbleException;
import io.dropwizard.Configuration;
import io.dropwizard.lifecycle.setup.LifecycleEnvironment;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Locale;

public class PebbleViewRenderer<T extends Configuration> implements ViewRenderer<T> {

	private final PebbleEngineConfigurable<T> pebbleEngineConfigurable;
	private final TemplateResolver templateResolver;
	private PebbleEngine pebbleEngine;

	public PebbleViewRenderer(PebbleEngineConfigurable<T> pebbleEngineConfigurable, TemplateResolver templateResolver) {
		this.pebbleEngineConfigurable = pebbleEngineConfigurable;
		this.templateResolver = templateResolver;
	}

	public void configure(LifecycleEnvironment lifecycleEnvironment, T configuration) {
		final PebbleEngine.Builder builder = new PebbleEngine.Builder();
		this.pebbleEngine = pebbleEngineConfigurable.configure(lifecycleEnvironment, configuration, builder);
	}

	public void render(PebbleView pebbleView, Locale locale, OutputStream output) throws IOException, PebbleException {
		try (final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(output)) {
			pebbleEngine.getTemplate(templateResolver.resolve(pebbleView)).evaluate(outputStreamWriter, pebbleView.getContext(), locale);
		}
	}
}

@@ -323,16 +323,49 @@
 Writer;%0A
+import java.nio.charset.Charset;%0A
 import j
@@ -1310,16 +1310,42 @@
 r(output
+, Charset.forName(%22UTF-8%22)
 )) %7B%0A%09%09%09

Fix the Charset to UTF-8