summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-03-23 14:22:10 +0100
committersnowleo <schneeleo@gmail.com>2012-03-23 14:22:10 +0100
commit8a22258945e4737230a977202128a581d4d3aeef (patch)
treef2e824cbf10dd95b70a1f9ff8fe96ca74e6b91a6
parent29a190f93a89c0b9d5532aadd7a84f16b1a4c736 (diff)
downloadEssentials-8a22258945e4737230a977202128a581d4d3aeef.tar
Essentials-8a22258945e4737230a977202128a581d4d3aeef.tar.gz
Essentials-8a22258945e4737230a977202128a581d4d3aeef.tar.lz
Essentials-8a22258945e4737230a977202128a581d4d3aeef.tar.xz
Essentials-8a22258945e4737230a977202128a581d4d3aeef.zip
Fix utf-8 decoding problems.
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsConf.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
index 846a7b4b0..89fb53d34 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
@@ -126,23 +126,25 @@ public class EssentialsConf extends YamlConfiguration
{
buffer.rewind();
data.clear();
- LOGGER.log(Level.INFO, "File {0} is not utf-8 encoded, trying {1}", new Object[]
- {
- configFile.getAbsolutePath().toString(), Charset.defaultCharset().displayName()
- });
+ LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + "is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
decoder = Charset.defaultCharset().newDecoder();
result = decoder.decode(buffer, data, true);
if (result.isError())
{
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
- } else {
+ }
+ else
+ {
decoder.flush(data);
}
- } else {
+ }
+ else
+ {
decoder.flush(data);
}
+ final int end = data.position();
data.rewind();
- super.loadFromString(data.toString());
+ super.loadFromString(data.subSequence(0, end).toString());
}
finally
{