title: Reading ZipEntry containing special characters while using Java SE6
body: <p><strong>UPDATED WITH SOLUTION, see at bottom</strong></p>
  
  <p><strong>Requirement</strong>:<br>
  Process a ZIP file in Java SE 6 that contains files with special characters in the file names. As the encoding (of the ZIP producer) is not UTF-8, special characters get encoded. Therefore I would like to correct special characters into their proper code.</p>
  
  <p><strong>Issue</strong>:<br>
  The ZIP contains a file called <code>abcüabc.txt</code> .
  The entry gets processed via <code>java.util.zip.ZipEntry</code> and when printing out single characters I see these characters (bytes):  </p>
  
  <p><code>ü</code> gets encoded as<br>
  <code>u</code> followed by a<br>
  <code>¨</code></p>
  
  <p><strong>Question</strong>:<br>
  So I would like to know how I can replace that <code>u¨</code> into <code>ü</code> or maybe <code>ue</code>:</p>
  
  <p>What I already tried and did not work out:<br>
  <code>name.replaceAll("u\\¨", "ue");</code><br>
  or<br>
  <code>name.replaceAll("ü", "ue");</code>  </p>
  
  <p><strong>Original Source Code (not working)</strong>:  </p>
  
  <pre><code>InputStream is = new FileInputStream(new File("/Users/me/Desktop/test.zip"));
  ZipInputStream zipStream = new ZipInputStream(is);
  ZipEntry zipEntry = null;
  while ((zipEntry = zipStream.getNextEntry()) != null) {
      String name = zipEntry.getName(); // reading abcüabc.txt
      System.out.println("pos 3: "+name.charAt(3));
      System.out.println("pos 4: "+name.charAt(4));
      System.out.println("is equal to ¨: "+Character.toString(name.charAt(4)).equals("¨"));
  }        
  </code></pre>
  
  <p>Output:  </p>
  
  <pre><code>pos 3: u
  pos 4:¨
  is equal to ¨: false
  </code></pre>
  
  <p><strong>Notes on my environment</strong>:</p>
  
  <p>Zip produced under Mac OS X 10.6.8<br>
  Java SE 6: Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)</p>
  
  <p><strong>SOLUTION</strong>  </p>
  
  <p>Obviously, the ZIP producer (in my case Mac OSX) converts special characters into a decomposed format. So a <code>ü</code> gets decomposed into <code>u¨</code>.<br>
  While extracting the file names form the ZIP, we would like to convert back from the decomposed to the composed format, so we only have to insert a normalization into our source code from above:</p>
  
  <pre><code>InputStream is = new FileInputStream(new File("/Users/me/Desktop/test.zip"));
  ZipInputStream zipStream = new ZipInputStream(is);
  ZipEntry zipEntry = null;
  while ((zipEntry = zipStream.getNextEntry()) != null) {
      String name = zipEntry.getName(); // reading abcüabc.txt
      System.out.println("pos 3: "+name.charAt(3));
      System.out.println("pos 4: "+name.charAt(4));
      System.out.println("contains ü: "+name.contains("ü"));
      name = Normalizer.normalize(name, Form.NFC);
      System.out.println("contains ü: "+name.contains("ü"));
  }        
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>pos 3: u
  pos 4:¨
  contains ü: false
  contains ü: true
  </code></pre>