title: How do I unzip a file containing entries with accented characters?
body: <p>I'm trying to write a simple routine to unzip a <code>.zip</code> file. Unfortunately, I cannot find a way to achieve this when an entry in the ZIP file contains non-ASCII characters, eg. accented characters from European languages. From what I can see this has long been an issue when working with ZIP files in Java. I haven't been able to get any of the suggestions I've found to work - all of which all focus on encoding.</p>
  
  <p>Here's a couple of my attempts:</p>
  
  <pre><code>File file = new File("/tmp/example.zip");
  try (ZipInputStream zis = new ZipInputStream(file.toURI().toURL().openStream(), StandardCharsets.UTF_8))
  {
      ZipEntry ze;
      while ((ze = zis.getNextEntry()) != null) {   // &lt;&lt;== Exception thrown here
          System.out.println(ze.getName() + ": " + ze.getSize());
      }
  }
  
  try (ZipFile z = new ZipFile(file, StandardCharsets.UTF_8))
  {
      Enumeration&lt;? extends ZipEntry&gt; entries = z.entries();
      while (entries.hasMoreElements()) {
          ZipEntry ze = entries.nextElement();   // &lt;&lt;== Exception thrown here
          System.out.println(ze.getName() + ": " + ze.getSize());
      }
  }
  </code></pre>
  
  <p>The key failure point is the construction of a <code>ZipEntry</code> when the entry's name has an accented character, ie. an <code>IllegalArgumentException</code> results.</p>
  
  <pre><code>java.lang.IllegalArgumentException: MALFORMED
      at java.util.zip.ZipCoder.toString(ZipCoder.java:58)
      at java.util.zip.ZipFile.getZipEntry(ZipFile.java:583)
      at java.util.zip.ZipFile.access$900(ZipFile.java:60)
      at java.util.zip.ZipFile$ZipEntryIterator.next(ZipFile.java:539)
      at java.util.zip.ZipFile$ZipEntryIterator.nextElement(ZipFile.java:514)
      at java.util.zip.ZipFile$ZipEntryIterator.nextElement(ZipFile.java:495)
  </code></pre>
  
  <p>If I vary the charset used, I get different results. <code>US_ASCII</code> and <code>UTF_16</code> result in the same exception. <code>ISO_8859_1</code> does not result in an exception, however the accented characters are not decoded correctly.</p>
  
  <p>My test file is created on Windows using the standard "Send to compressed folder" feature. I can unzip the file from the command line correctly.</p>
  
  <p>Update: I tried using the Apache Commons Compress library and ran into essentially the same issue, ie. it too could not handle such entries.</p>
  
  <p>Any thoughts on whether and how I can unzip a ZIP file with entries containing accented characters?</p>