Mojira Archive
MC-2215

Encoding errors in server.properties

The bug

The server.properties file doesn't seems to handle unicode UTF-8 correctly, while still trying to recode it as such. This is most apparent on motd where you can't type non-ascii characters and save it as UTF-8.

For example if trying to change motd to "motd=§lA Minecraft Server", when the server starts, the properties file change it into "motd=\u00C2\u00A7lA Minecraft Server" and the multiplayer screen shows gibberish.

You can though somehow overcome this by encode the file as latin1 (iso-8859-1). While the server.properties still gets changed into "motd=\u00A7lA Minecraft Server", at least it shows up correctly in the multiplayer list.

This happens off course for all non-ascii characters, like ß, Å, etc.

Cause and suggested fix from Orthotope:

Looking at the code, the problem here is the use of the java.util.Properties.load(InputStream) and Properties.store(OutputStream, String) methods. Both of these assume the use of ISO 8859-1 encoding, and this cannot be changed. The solution is to use the Properties.load(Reader) and Properties.store(Writer, String) methods instead; InputStreamReader and OutputStreamWriter can be used to wrap the FileInputStream and FileOutputStream respectively and specify the UTF-8 charset.