diff --git a/library/src/main/java/org/mustangproject/XMLTools.java b/library/src/main/java/org/mustangproject/XMLTools.java index 402a6dfd..51b80ec5 100644 --- a/library/src/main/java/org/mustangproject/XMLTools.java +++ b/library/src/main/java/org/mustangproject/XMLTools.java @@ -98,7 +98,7 @@ public class XMLTools extends XMLWriter { * @param is the ByteArrayInputStream used * @throws IOException if can not be read from is * @see Autodetection of Character Encodings - */ + * public static int guessBOMSize(ByteArrayInputStream is) throws IOException { byte[] pad = new byte[4]; is.read(pad); @@ -118,7 +118,7 @@ public class XMLTools extends XMLWriter { return 2; } return 0; - } + }*/ /*** * removes utf8 byte order marks from byte arrays, in case one is there diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index 87a5c120..783f9000 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -171,7 +171,7 @@ public class ZUGFeRDImporter { xmlFact.setNamespaceAware(false); DocumentBuilder builder = xmlFact.newDocumentBuilder(); ByteArrayInputStream is = new ByteArrayInputStream(rawXML); - is.skip(guessBOMSize(is)); + /// is.skip(guessBOMSize(is)); document = builder.parse(is); } @@ -187,33 +187,6 @@ public class ZUGFeRDImporter { } - /** - * Skips over a BOM at the beginning of the given ByteArrayInputStream, if one exists. - * - * @param is the ByteArrayInputStream used - * @throws IOException if can not be read from is - * @see Autodetection of Character Encodings - */ - private int guessBOMSize(ByteArrayInputStream is) throws IOException { - byte[] pad = new byte[4]; - is.read(pad); - is.reset(); - int test2 = ((pad[0] & 0xFF) << 8) | (pad[1] & 0xFF); - int test3 = ((test2 & 0xFFFF) << 8) | (pad[2] & 0xFF); - int test4 = ((test3 & 0xFFFFFF) << 8) | (pad[3] & 0xFF); - // - if (test4 == 0x0000FEFF || test4 == 0xFFFE0000 || test4 == 0x0000FFFE || test4 == 0xFEFF0000) { - // UCS-4: BOM takes 4 bytes - return 4; - } else if (test3 == 0xEFBBFF) { - // UTF-8: BOM takes 3 bytes - return 3; - } else if (test2 == 0xFEFF || test2 == 0xFFFE) { - // UTF-16: BOM takes 2 bytes - return 2; - } - return 0; - } protected String extractString(String xpathStr) {