title: Correctly decoding zip entry file names -- CP437, UTF-8 or?
body: <p>I recently wrote a zip file I/O library called <a href="https://github.com/pixelglow/zipzap" rel="noreferrer">zipzap</a>, but I'm struggling with correctly decoding zip entry file names from arbitrary zip files.</p>
  
  <p>Now, the <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT" rel="noreferrer">PKWARE spec</a> states:</p>
  
  <blockquote>
    <p>D.1 The ZIP format has historically supported only the original IBM PC character 
    encoding set, commonly referred to as IBM Code Page 437...</p>
    
    <p>D.2 If general purpose bit 11 is unset, the file name and comment should conform 
    to the original ZIP character encoding.  If general purpose bit 11 is set, the 
    filename and comment must support The Unicode Standard, Version 4.1.0 or 
    greater using the character encoding form defined by the UTF-8 storage 
    specification...</p>
  </blockquote>
  
  <p>which means that conforming zip files encode file names as CP437, unless the EFS bit is set, in which case the file names are UTF-8.</p>
  
  <p>Unfortunately it seems that a lot of zip tools either don't set the EFS bit correctly (e.g. Mac CLI, GUI zip) or use some other encoding, typically the default system one (e.g. WinZip?). If you know how WinZip, 7-Zip, Info-Zip, PKZIP, Java JAR/Zip, .NET zip, dotnetzip, etc. encode file names and what they set their "version made by" field to when <em>zipping</em>, please tell me.</p>
  
  <p>In particular, Info-Zip tries this when <em>unzipping</em>:</p>
  
  <ul>
  <li>File system = MS-DOS (0) => CP437
  
  <ul>
  <li>except: version = 2.5, 2.6, 4.0 => ISO 8859-1</li>
  </ul></li>
  <li>File system = HPFS (6) => CP437</li>
  <li>File system = NTFS (10) and version = 5.0 => CP437</li>
  <li>otherwise, ISO 8859-1</li>
  </ul>
  
  <p><strong>If I want to support inspecting or extracting from arbitrary zip files and make a <em>reasonable</em> attempt at the file name encoding</strong> without the EFS flag, what can I look for?</p>