odftoolkit icon indicating copy to clipboard operation
odftoolkit copied to clipboard

Character encoding error when creating new spreadsheet

Open pnemonic78 opened this issue 2 years ago • 3 comments

Error exporting: java.nio.charset.CharsetICU[UTF-8]
  java.nio.charset.IllegalCharsetNameException: java.nio.charset.CharsetICU[UTF-8]
  at java.nio.charset.Charset.checkCharsetName(Charset.java:201)
  at java.nio.charset.Charset.forName(Charset.java:295)
  at org.apache.commons.compress.archivers.zip.ZipEncodingHelper.getZipEncoding(ZipEncodingHelper.java:58)
  at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.<init>(ZipArchiveInputStream.java:431)
  at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.<init>(ZipArchiveInputStream.java:408)
  at org.odftoolkit.odfdom.pkg.ZipHelper.createZipInputStream(ZipHelper.java:61)
  at org.odftoolkit.odfdom.pkg.ZipHelper.entriesToMap(ZipHelper.java:81)
  at org.odftoolkit.odfdom.pkg.OdfPackage.readZip(OdfPackage.java:529)
  at org.odftoolkit.odfdom.pkg.OdfPackage.initializeZip(OdfPackage.java:509)
  at org.odftoolkit.odfdom.pkg.OdfPackage.<init>(OdfPackage.java:318)
  at org.odftoolkit.odfdom.pkg.OdfPackage.loadPackage(OdfPackage.java:389)
  at org.odftoolkit.odfdom.doc.OdfDocument.loadTemplate(OdfDocument.java:180)
  at org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument.newSpreadsheetDocument(OdfSpreadsheetDocument.java:79)

pnemonic78 avatar Sep 21 '23 08:09 pnemonic78

Suggestion:

replace in ZipHelper return new ZipArchiveInputStream(is, StandardCharsets.UTF_8.toString(), true, true); with return new ZipArchiveInputStream(is, StandardCharsets.UTF_8.name(), true, true);

pnemonic78 avatar Sep 21 '23 08:09 pnemonic78

Nice catch! Thank you! Do you have some simplified test document to reproduce the issue? Most welcome would be a patch of yours where there is a test involved that earlier fails and with your patch would be working! Thanks in advance!

Greetings from the LibreOffice Conference in Bukarest! :-) Svante

svanteschubert avatar Sep 21 '23 08:09 svanteschubert

@pnemonic78 How are we able to reproduce this issue? We need some more data to fix this! Thanks in advance!

svanteschubert avatar May 13 '25 19:05 svanteschubert