diff --git a/README b/README index 9de7726..014c72a 100644 --- a/README +++ b/README @@ -191,6 +191,8 @@ createConflict=Gate conflicts with existing gate ============= Changes ============= +[Version 0.6.9] + - Added UTF8 support for lang files (With or without BOM) [Version 0.6.8] - Fixed unmanned carts losing velocity through gates - /sg reload now properly switches languages diff --git a/src/net/TheDgtl/Stargate/LangLoader.java b/src/net/TheDgtl/Stargate/LangLoader.java index d4a9142..d78e8b8 100644 --- a/src/net/TheDgtl/Stargate/LangLoader.java +++ b/src/net/TheDgtl/Stargate/LangLoader.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.Set; public class LangLoader { + private String UTF8_BOM = "\uFEFF"; // Variables private String datFolder; private String lang; @@ -83,10 +84,14 @@ public class LangLoader { FileInputStream fis = null; try { fis = new FileInputStream(datFolder + lang + ".txt"); - InputStreamReader isr = new InputStreamReader(fis); + InputStreamReader isr = new InputStreamReader(fis, "UTF8"); BufferedReader br = new BufferedReader(isr); String line = br.readLine(); + boolean firstLine = true; while (line != null) { + // Strip UTF BOM + if (firstLine) line = removeUTF8BOM(line); + firstLine = false; // Split at first "=" int eq = line.indexOf('='); if (eq == -1) { @@ -115,4 +120,11 @@ public class LangLoader { Stargate.debug("LangLoader::Debug", key + " => " + strList.get(key)); } } + + private String removeUTF8BOM(String s) { + if (s.startsWith(UTF8_BOM)) { + s = s.substring(1); + } + return s; + } } diff --git a/src/plugin.yml b/src/plugin.yml index f0a0955..4fe7ed4 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: Stargate main: net.TheDgtl.Stargate.Stargate -version: 0.6.7-dev +version: 0.6.9 description: Stargate mod for Bukkit author: Drakia website: http://www.thedgtl.net