Reputation: 290
Summary
I have a problem with String encoding and GAE that I cannot solve. Basically I have a classic encoding problem where special characters like ñ, é, ü, show up like ��� in both the datastore viewer and the client, but, only in production mode.
I save data to the datastore through two mechanisms: - User input : this works perfect in both dev mode and production - 3rd party API : this one works on dev mode but not in production
Following the data
Content-Type:text/html; charset=utf-8
I have my Eclipse configured for UTF-8. I think that is the main reason why everything works very well in development mode.
I have not been able yet to find how to set the production JVM to UTF-8 (I read here that the default is US-ASCII and it may not be possible to change that) - In dev mode, I have eclipse configured to use UTF-8 - In production mode I have followed the advices by this guy but it does not change the behavior:
Top-level appengine-web.xml:
<system-properties>
<!-- Configure java.util.logging -->
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
<!-- UTF-8 Support -->
<property name="file.encoding" value="UTF-8" />
</system-properties>
<!-- UTF-8 Support -->
<env-variables>
<env-var name="DEFAULT_ENCODING" value="UTF-8" />
</env-variables>
I do not know what else to do to fix it. Does any one have a workaround for this problem?
Upvotes: 4
Views: 1514
Reputation: 290
Well, unfortunately based on the lack of answers here, I think there is no way to set-up UTF-8 as the default encoding on GAE's production JVM.
In the case that was haunting me above, my problem was that I was reading the 3rd party API request using the default encoding, which in production GAE is US-ASCII:
BufferedReader reader =
new BufferedReader(new InputStreamReader(url.openStream());
Changing the line above to
BufferedReader reader =
new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8");
solves the issue.
Upvotes: 3