actually this line is not needed at all and it's not really used. We're passing StringWriter to StreamResult and that's character stream so it doesn't have control over what encoding is actually used.