Use UTF-8 instead of ISO 8859-1 when loading/saving config

In order to prevent failures on reading/writing incorrectly escaped
characters or writing special UTF-8 characters on save as gibberish,
explicitly specify UTF-8 encoding when loading and writing properties.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-10-10 16:14:57 +02:00
parent 4a5e4491c9
commit 85c9ec890b

View File

@@ -36,9 +36,12 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.nio.charset.Charset;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@@ -179,7 +182,7 @@ public class ConfigManager
try (FileInputStream in = new FileInputStream(propertiesFile)) try (FileInputStream in = new FileInputStream(propertiesFile))
{ {
properties.load(in); properties.load(new InputStreamReader(in, Charset.forName("UTF-8")));
} }
catch (FileNotFoundException ex) catch (FileNotFoundException ex)
{ {
@@ -226,7 +229,7 @@ public class ConfigManager
try (FileOutputStream out = new FileOutputStream(propertiesFile)) try (FileOutputStream out = new FileOutputStream(propertiesFile))
{ {
properties.store(out, "RuneLite configuration"); properties.store(new OutputStreamWriter(out, Charset.forName("UTF-8")), "RuneLite configuration");
} }
} }