From b335b5bb43984e02a569e3f762f8e9e893c8fed1 Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Mon, 2 Sep 2019 06:24:46 -0500 Subject: [PATCH] process BOM before checking for comments --- src/main/java/com/songoda/core/locale/Locale.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/core/locale/Locale.java b/src/main/java/com/songoda/core/locale/Locale.java index 38b11ee2..31825e84 100644 --- a/src/main/java/com/songoda/core/locale/Locale.java +++ b/src/main/java/com/songoda/core/locale/Locale.java @@ -262,8 +262,6 @@ public class Locale { BufferedReader reader = new BufferedReader(new InputStreamReader((InputStream) stream, charset));) { String line; for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) { - if ((line = line.trim()).isEmpty() || line.startsWith("#") /* Comment */) continue; - if (lineNumber == 0){ // remove BOM markers, if any line = line.replaceAll("[\uFEFF\uFFFE\u200B]", ""); @@ -274,6 +272,8 @@ public class Locale { line = new String(encoded, 0, encoded.length, StandardCharsets.UTF_8); } */ + if ((line = line.trim()).isEmpty() || line.startsWith("#") /* Comment */) continue; + Matcher matcher = NODE_PATTERN.matcher(line); if (!matcher.find()) { System.err.println("Invalid locale syntax at (line=" + lineNumber + "): " + line);