= fixed UTF_8 formatting issue for config output

This commit is contained in:
Matthew Cech
2019-06-23 01:58:35 -07:00
parent da699281e9
commit 227bf29b10
3 changed files with 392 additions and 92 deletions
+8
View File
@@ -57,9 +57,13 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection
keyList.add(key);
if(value.equalsIgnoreCase(enabled))
{
enabledMap.putIfAbsent(key, true);
}
else
{
enabledMap.putIfAbsent(key, false);
}
});
}
@@ -92,7 +96,9 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection
String value = enabled.toLowerCase();
if(enabledMap.get(key) == false)
{
value = disabled.toLowerCase();
}
list.add(new Pair<String, String>(key, value));
}
@@ -108,7 +114,9 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection
String toCheck = key.toLowerCase();
if(enabledMap.containsKey(toCheck))
{
return enabledMap.get(toCheck);
}
return true;
}
+6 -7
View File
@@ -1,8 +1,10 @@
package core;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Vector;
import utils.GlobalLog;
@@ -84,14 +86,11 @@ public class Config
// Form updated data as necessary for autogeneration
String output = combineConfigs();
String path = configFile.getPath();
// Write to file.
FileWriter fileWriter;
try
{
fileWriter = new FileWriter(path);
OutputStreamWriter fileWriter = new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8);
fileWriter.write(output);
fileWriter.close();
}
@@ -118,7 +117,7 @@ public class Config
else
{
String sectionContents = parsedSections.getOrDefault(currentHeader, "");
parsedSections.put(currentHeader, sectionContents);
parsedSections.put(currentHeader, sectionContents + line + pairSeparator);
}
}