Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It took some time but I think I found the answer.</p> <p>I assumed the word was supposed to be Akvaléir. I found a page description about that, in French. When I used your code snippet I had a string like</p> <pre><code>&gt;&gt;&gt; fileinfo.filename 'Akval\x82ir, La police - The Font - Fr - En.pdf' &gt;&gt;&gt; </code></pre> <p>That didn't work at UTF8, Latin-1, CP-1251 or CP-1252 encodings. I then found that CP863 was a possible Canadian encoding, so perhaps this was from French Canada.</p> <pre><code>&gt;&gt;&gt; print unicode(fileinfo.filename, "cp863").encode("utf8") Akvaléir, La police - The Font - Fr - En.pdf &gt;&gt;&gt; </code></pre> <p>However, I then read the <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT" rel="noreferrer">Zip file format specification</a> which says</p> <blockquote> <p>The ZIP format has historically supported only the original IBM PC character encoding set, commonly referred to as IBM Code Page 437.</p> <p>...</p> <p>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>Testing that out gives me the same answer as the Canadian code page</p> <pre><code>&gt;&gt;&gt; print unicode(fileinfo.filename, "cp437").encode("utf8") Akvaléir, La police - The Font - Fr - En.pdf &gt;&gt;&gt; </code></pre> <p>I don't have a Unicode encoded zip file and I'm not going to create one to find out, so I'll just assume that all zip files have the cp437 encoding.</p> <pre><code>import shutil import zipfile f = zipfile.ZipFile('akvaleir.zip', 'r') for fileinfo in f.infolist(): filename = unicode(fileinfo.filename, "cp437") outputfile = open(filename, "wb") shutil.copyfileobj(f.open(fileinfo.filename), outputfile) </code></pre> <p>On my Mac that gives</p> <pre><code> 109936 Nov 27 01:46 Akvale??ir_Normal_v2007.ttf 25244 Nov 27 01:46 Akvale??ir, La police - The Font - Fr - En.pdf </code></pre> <p>which tab-completes to</p> <pre><code>ls Akvale\314\201ir </code></pre> <p>and shows up with a nice 'é' in my file browser.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload