Skip to content

ZUGFeRDImporter encoding problem #900

@asdf00000

Description

@asdf00000

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions