I went back and reviewed our testing and configuration around this.
Our use-case was actually more around reading UTF-8 templates but injecting locale-specific data into them.
What we might need to do in this case, is to update FreemarkerViewRenderer.render() to do something like {
try {
final Configuration configuration = configurationCache.getUnchecked(view.getClass());
final String targetEncoding = view.getEncoding() != null ? view.getEncoding() : configuration.getEncoding(locale);
final Template template = view.getEncoding() != null ? view.configuration.getTemplate(view.getTemplateName(), locale, targetEncoding);
template.process(view, new OutputStreamWriter(output, template.getEncoding()));
} catch (TemplateException e) {
throw new ContainerException(e);
}
}
(I haven't tried this code yet, but from looking at the stack, it should override the defaults)
To test whether passing the encoding does the trick, you can create:
src/main/resources/META-INF/services/com.yammer.dropwizard.views.ViewRenderer w/ the contents:
MyViewRenderer is a clone of FreemarkerViewRenderer with the requisite changes.
I did something very similar to this a couple releases back when I needed to roll out the modified view renderer without it being in dropwizard core yet. Of course locally you could just compile against a SNAPSHOT and give it a quick test.
Cheers,
Adam