Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-2215

Encoding errors in server.properties

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.20 Pre-release 1
    • Minecraft 1.4.2, Minecraft 1.4.3, Minecraft 1.4.4, Minecraft 1.4.7, Minecraft 1.5, Minecraft 1.6.2, Minecraft 1.6.4, Minecraft 1.7.1, Minecraft 1.7.2, Minecraft 1.7.4, Minecraft 14w05b, Minecraft 14w06b, Minecraft 14w07a, Minecraft 14w08a, Minecraft 1.8, Minecraft 15w49b, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 18w16a, Minecraft 1.13.1, 1.14.4, 1.16.1, 20w27a, 1.18.2, 1.19.3, 23w05a
    • Confirmed
    • Text
    • Normal

      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.

            boq [Mojang] Bartosz Bok
            azatoth Carl Fürstenberg
            Votes:
            32 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: