-
-
Notifications
You must be signed in to change notification settings - Fork 184
Open
Description
When the default charset of the JVM is not UTF-8, getUTF8()
in ZUGFeRDImporter
does return an incorrectly encoded XML string.
How to reproduce the issue:
public static void main(String[] arg) {
Path p = Paths.get("invoice.pdf");
try (InputStream input = Files.newInputStream(p)) {
ZUGFeRDImporter zi = new ZUGFeRDImporter(input);
String xml = zi.getUTF8();
System.out.println(xml);
} catch (IOException e) {
e.printStackTrace();
}
}
Run this with -Dfile.encoding=ISO-8859-1
. It will return an XML-String that contains for example München
instead of München
.
To fix it, set the encoding explicitly to UTF-8 in getUTF()
public String getUTF8() {
...
return new String(bomlessData, StandardCharsets.UTF_8);
}
I made a pull request.
Metadata
Metadata
Assignees
Labels
No labels