fredsa / playn

Cross platform game library for N≥4 platforms
0 stars 1 forks source link

Read text assets with UTF-8 #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Purpose of code changes on this branch:
The Java implementation was using a FileReader to read text assets, and 
FileReader uses the JVM's default charset to turn bytes into Strings. That 
varies by OS, so this commit specifies UTF-8 as the encoding.

UTF-8 felt like a good choice for a few reasons: 

* The HTML implementation uses XMLHttpRequest to load text, and the 
XMLHttpRequest recommendation "strongly encourages" authors to encode their 
resources using UTF-8.
* Json's default encoding is UTF-8.
* UTF-8 is a pretty common default encoding in general.

This means webservers will need to be configured to serve up text assets using 
UTF-8, but something like that would be necessary anyway.

I added a dependency on Guava to the java implementation to make the text 
reading cleaner, more efficient, and more robust and to make it easier to 
specify UTF-8. Guava's a pretty small dependency and quite stable, so it felt 
like a worthwhile addition. I'm sure additional bits of the java implementation 
could use the various niceties of Guava.

When reviewing my code changes, please focus on:
https://github.com/threerings/playn/commit/3bbd526530128bad029145123490cd73ab581
434
https://github.com/threerings/playn/commit/5b7f2989cfda13768148edee0bcf77cbb9dc6
8ba

After the review, I'll merge this branch into:
/trunk

Original issue reported on code.google.com by charlie....@gmail.com on 14 Sep 2011 at 4:52

GoogleCodeExporter commented 9 years ago

Original comment by charlie....@gmail.com on 14 Sep 2011 at 4:52

GoogleCodeExporter commented 9 years ago
LGTM. If concern is raised about the Guava dependency (pretty harmless now that 
everything is done via Maven and the Java backend is isolated from the other 
backends), we can remove it later. I don't see a good reason to do so though, 
since it only comes into play when developing locally and does not impact any 
of the production backends.

Original comment by samskiv...@gmail.com on 15 Sep 2011 at 8:09

GoogleCodeExporter commented 9 years ago
Committed.

Original comment by charlie....@gmail.com on 15 Sep 2011 at 8:32