The sourcecode of my webapp is written in UTF-8 encoded files. It is deployed to different Tomcat servers which either use UTF-8 encoding or CP-1252. While everything is fine on the Tomcats with UTF-8 encoding, the CP-1252 Tomcats have problems with special characters like Umlauts in strings (e.g. for database queries).
- I have no access to the Tomcat configurations, so I can't just switch all to UTF-8.
- I could replace all Umlauts with unicode escapes, but that is error prone, since it can be forgotten.
- Same applies to recoding each string with new String(value.getBytes(), StandardCharsets.UTF_8)
So is there any solution to this problem? Searching for encoding and Tomcat leads always to "yeah, edit server.xml of your Tomcat and change encoding to UTF-8" which doesn't help me.