Changing default encoding in Java runtime to UTF-8

Problem

App Engine Standard Java runtimes use US-ASCII encoding by default instead of UTF-8. Many Java libraries require the encoding to be UTF-8 which results in runtime errors.

Environment

  • App Engine Standard Java 8/11 runtime

Solution

  1. To set the default encoding in production, as reported by the file.encoding system property and by Charset.defaultCharset() to UTF-8, the following should be added to the appengine-web.xml file:
     <system-properties>
            <property name="appengine.file.encoding" value="UTF-8" />
     </system-properties> 

Cause

The default encoding has been US-ASCII and changing this to UTF-8 for every app would break lots of apps that are depending on the current default.