Skip to content

Commit

Permalink
partial fix for listing non-ASCII filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
srirangav committed Jun 25, 2021
1 parent 584c113 commit 3d396b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
README
------

qlZipInfo v1.1.1
qlZipInfo v1.1.2
By Sriranga Veeraraghavan <[email protected]>

qlZipInfo is a QuickLook generator for zip, jar, tar, tar.gz
Expand Down Expand Up @@ -37,6 +37,7 @@ Supported MacOSX versions:

History:

v1.1.2 - fix (partially?) listing non-ASCII filenames
v1.1.1 - add support for xar / pkg, debian (.deb), 7zip
(.7z), xz, and lha archives and ISO9660 images
v1.1.0 - switch to libarchive and add support for .tar,
Expand Down
4 changes: 2 additions & 2 deletions qlZipInfo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@
INFOPLIST_FILE = qlZipInfo/Info.plist;
INSTALL_PATH = /Library/QuickLook;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = "org.calalum.ranga.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -883,7 +883,7 @@
INFOPLIST_FILE = qlZipInfo/Info.plist;
INSTALL_PATH = /Library/QuickLook;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = "org.calalum.ranga.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
35 changes: 19 additions & 16 deletions qlZipInfo/GeneratePreviewForURL.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ a copy of this software and associated documentation files (the

#include <sys/syslimits.h>
#include <sys/stat.h>
#include <iconv.h>

#include "config.h"
#include "archive.h"
Expand Down Expand Up @@ -184,6 +185,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface,
NSString *qlEntryIcon = nil;
NSMutableString *qlHtml = nil;
NSMutableString *fileDateStringInZip = nil;
NSMutableString *localeString = nil;
NSDateFormatter *fileDateFormatterInZip = nil;
NSDateFormatter *fileLocalDateFormatterInZip = nil;
NSDate *fileDateInZip = nil;
Expand Down Expand Up @@ -255,6 +257,23 @@ file path using CFStringGetCString() b/c the file path
return noErr;
}

/*
set the locale to UTF-8 to decode non-ASCII filenames:
https://github.com/libarchive/libarchive/issues/587
https://github.com/libarchive/libarchive/issues/1535
https://stackoverflow.com/questions/1085506/how-to-get-language-locale-of-the-user-in-objective-c
https://developer.apple.com/documentation/foundation/nslocale/1416263-localeidentifier?language=objc
*/

localeString = [[NSMutableString alloc] init];
[localeString appendString:
[[NSLocale currentLocale] localeIdentifier]];
[localeString appendString: @".UTF-8"];

setlocale (LC_ALL, [localeString UTF8String]);

a = archive_read_new();

archive_read_support_filter_compress(a);
Expand Down Expand Up @@ -515,23 +534,7 @@ file path using CFStringGetCString() b/c the file path

if (fileNameInZip == NULL)
{
#ifdef SKIP_ENTRY
/*
skip this entry - could be b/c of a filename
encoding issue
*/

[qlHtml appendString: @"<tr>"];
[qlHtml appendFormat: @"<td align=\"center\">%@</td>",
gFileUnknownIcon];
[qlHtml appendString:
@"<td colspan=\"5\">[Skipped]</td>"];
[qlHtml appendString: @"</tr>\n"];

continue;
#else
fileNameInZip = gFileNameUnavilable;
#endif
}

isFolder =
Expand Down

0 comments on commit 3d396b1

Please sign in to comment.