process BOM before checking for comments

This commit is contained in:
jascotty2 2019-09-02 06:24:46 -05:00
parent 538e364674
commit b335b5bb43

View File

@ -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);