title: Google AppEngine - How to set default Charset / file-encoding (to UTF-8) for Google AppEngine
body: <p><strong>Situation</strong></p>
  
  <p>I'm using <a href="https://cloud.google.com/appengine/docs/java/endpoints/" rel="nofollow noreferrer">AppEngine Cloud Endpoints (Java)</a> as backendserver for my Android-application. In a Cron-Job the server regularly downloads new data (String), filters out relevant information and sends it via Firebase Cloud Messaging to different topics (by posting HTTP-Request to <a href="https://fcm.googleapis.com/fcm/send" rel="nofollow noreferrer">https://fcm.googleapis.com/fcm/send</a>).</p>
  
  <p><strong>The (damn simple) Problem</strong></p>
  
  <p>The downloaded text is in German, containing letters like ä,ö,ü,ß and (to not have the famous ?s istead of these characters) <strong><em>I want to change the encoding to UTF-8</em></strong>. </p>
  
  <p>US-ASCII encoding is the default when deployed to AppEngine (why isn't it UTF-8 by default...). When tested locally, the default encoding of my computer is used which is UTF-8 and <strong><em>everything is working just fine</em></strong>.</p>
  
  <p>So all I want is <code>Charset.getDefaultCharset()</code> to return <code>UTF-8</code>.<br>
  How do I achieve this?
  Thanks in advance, all help appreciated.</p>
  
  <p><strong>What I've tried</strong></p>
  
  <ul>
  <li><p>adding this to appengine-web.xml:</p>
  
  <p><code>&lt;env-variables&gt;
      &lt;env-var name="DEFAULT_ENCODING" value="UTF-8" /&gt;
   &lt;/env-variables&gt;</code>  </p>
  
  <p>When testing locally I got IncorrectEnvironmentVariableException. When deployed encoding was still ASCII.</p></li>
  <li><p>adding this to <code>&lt;system-properties&gt;</code>-tag in appengine-web.xml: </p>
  
  <p><code>&lt;property name="file.encoding" value="UTF-8" /&gt;
   &lt;property name="DEFAULT_ENCODING" value="UTF-8" /&gt;</code></p>
  
  <p>changed nothing, not only when deployed but also when I tried to use this to set the encoding to US-ASCII on local developement server, still UTF-8 was returned by <code>Charset.getDefaultCharset()</code></p></li>
  <li><p>even tried to use reflection:</p>
  
  <p><code>System.setProperty("file.encoding","UTF-8");
   Field charset = Charset.class.getDeclaredField("defaultCharset");
   charset.setAccessible(true);
   charset.set(null,null);</code> </p>
  
  <p>(caused IllegalAccessException)</p></li>
  <li><p>tried setting encoding as content-type-property with the HTTP-post (didn't work):</p>
  
  <p><code>connection.setRequestProperty("Content-Type", application/json; charset=UTF-8);</code></p></li>
  </ul>