This code not set the response encoding :
res.setEntity(resultDocument.asXML(), MediaType.TEXT_XML);
by default this setEntity generate a StringRepresentation with charSet set to Null.
And for americans, it's logic to create StringRepresentation like that :
public StringRepresentation(CharSequence text, MediaType mediaType,
Language language)
In com.noelios.restlet.http.HttpServerConverter.addResponseHeaders implements that :
if (entity.getMediaType() != null) {
StringBuilder contentType = new StringBuilder(entity
.getMediaType().getName());
if (entity.getCharacterSet() != null)
{ // Specify the character set parameter contentType.append("; charset=").append( entity.getCharacterSet().getName()); } responseHeaders.add(HttpConstants.HEADER_CONTENT_TYPE,
contentType.toString());
}
So we need to create explicitly StringRepresentation and add characterSet in the representation (che) :
Representation rep = new StringRepresentation(resultDocument.asXML(), MediaType.TEXT_XML);
rep.setCharacterSet(CharacterSet.UTF_8);
res.setEntity(rep);