Is there a way to configure Jetty in Dropwizard to use UTF-8 encoding in the output? I have a suspicion Jetty is causing a problem I'm seeing: foreign characters display in the browser as a black diamond with question mark. Additional info:
I have a method like this:
@GET
@Path("/foo")
@Produces(MediaType.TEXT_HTML)
public View foo()
{
// returns a View constructed with a Freemarker template
}
The Freemarker template has some variables inserted in it (e.g. ${someString}). Those variables are rendered as what appears to be ISO-8859-1, NOT as UTF-8, despite:
* All source files and templates (Freemarker) being UTF-8 encoded
* Maven configured to use UTF-8 (maven-resources-plugin and maven-compiler-plugin)
* Having set JVM option: -Dfile.encoding=UTF-8 (also tried environment variable LANG=en_US.UTF-8)
* The browser's encoding is set to UTF-8
* The variable text is stored in the DB as UTF-8.
* The variable text retrieved from the DB is correct when inspected in a debugger.
In this case the characters are have umlaut diacritics (i.e. German) and they display in the browser as a black diamond with question mark.
Further diagnostics:
* I put a character with an umlaut diacritic in the template. Result: character renders correctly.
* I had the Freemarker template output the encoding its using via: ${.output_encoding!"Not set"}. Result: no encoding is set.
I'm sure I'm not the first user of the Dropwizard stack to run into this gotcha, and I'm wondering if I'm overlooking a setting somewhere to ensure UTF-8 encoding is used.
Thanks,
Rob