have tests for visualization and ubl convert. Insist in UTF-8 as charset in more cases.

This commit is contained in:
jstaerk
2021-02-02 08:05:10 +01:00
parent 0763ade64e
commit e142a81959
13 changed files with 1679 additions and 9 deletions

View File

@@ -18,6 +18,8 @@
*********************************************************************** */
package org.mustangproject.ZUGFeRD;
import java.nio.charset.StandardCharsets;
public class CustomXMLProvider implements IXMLProvider {
protected byte[] zugferdData;
@@ -29,7 +31,7 @@ public class CustomXMLProvider implements IXMLProvider {
}
public void setXML(byte[] newData) {
String zf = new String(newData);
String zf = new String(newData, StandardCharsets.UTF_8);
if (!zf.contains("CrossIndustry")) {
throw new RuntimeException("ZUGFeRD XML does not contain (<rsm:)CrossIndustry and can thus not be valid");
}

View File

@@ -23,6 +23,7 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
@@ -77,7 +78,7 @@ public class ZUGFeRDVisualizer {
FileInputStream fis=new FileInputStream(xmlFilename);
String fileContent="";
try {
fileContent = new String(Files.readAllBytes(Paths.get(xmlFilename)));
fileContent = new String(Files.readAllBytes(Paths.get(xmlFilename)), StandardCharsets.UTF_8);
} catch (IOException e2) {
LOG.log(Level.SEVERE, null, e2);
}