`ZipArchive`: added support for UTF8 encoded filenames jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 15 Jun 2017 15:21:14 +0100
branchjv
changeset 4484 d9fdadaba27e
parent 4483 3563e89f551b
child 4681 87d6e69daf7b
`ZipArchive`: added support for UTF8 encoded filenames For now, it only supports if UTF8 filenames if bit 11 of general purpose bit flag is set (see ZIP spec [1]. section 4.4.4) UTF8 filename specified by -Info-ZIP Unicode Path Extra Field (see ZIP spec [1]. section 4.6.9) is not yet supported. [1]: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
ZipArchive.st
--- a/ZipArchive.st	Fri Mar 17 23:03:26 2017 +0000
+++ b/ZipArchive.st	Thu Jun 15 15:21:14 2017 +0100
@@ -4959,6 +4959,14 @@
 "/    ].
     fileName:= String new:fileNameLength.
     aStream nextBytes:fileNameLength into:fileName.
+    "/ If bit 11 of general purpose bit flag is 1, then
+    "/ fileName is UTF8 encoded.
+    "/ 
+    "/ See ZIP spec, section 4.4.4
+    "/ https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
+    (generalPurposBitFlag isBitSet: 12"1-based indexing") ifTrue:[ 
+        fileName := fileName utf8Decoded.
+    ].
 
     extraFieldLength ~~ 0 ifTrue: [
 "/        (aStream position + extraFieldLength) > endOfArchive ifTrue: [
@@ -4974,7 +4982,18 @@
 "/        ].
         fileComment := String new:fileCommentLength.
         aStream nextBytes:fileCommentLength into:fileComment.
+        "/ If bit 11 of general purpose bit flag is 1, then
+        "/ fileName is UTF8 encoded.
+        "/ 
+        "/ See ZIP spec, section 4.4.4
+        "/ https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
+        (generalPurposBitFlag isBitSet: 12"1-based indexing") ifTrue:[ 
+            fileComment := fileComment utf8Decoded.
+        ].
+
     ].
+
+    "Modified: / 15-06-2017 / 13:41:46 / jv"
 !
 
 rewriteCrcAndSizeTo:aStream