Skip to content

Commit

Permalink
Merge branch 'comawill-pull-req/LC_ALL'
Browse files Browse the repository at this point in the history
  • Loading branch information
tsdorsey committed Oct 11, 2016
2 parents 33e477e + 2d47f6a commit 171426b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions QuickLookStephenProject/QLSFileAttributes.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ + (instancetype)attributesForItemAtURL:(NSURL *)aURL {
return nil;
}

NSString *magicString = [self magicStringForItemAtURL:aURL];
NSString *magicString = [self magicStringForItemAtURL:aURL usingLcALL:@"en_US.UTF-8"];
if (!magicString) magicString = [self magicStringForItemAtURL:aURL usingLcALL:@"C"];
if (!magicString) return nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\S+/\\S+); charset=(\\S+)" options:0 error:nil];
NSTextCheckingResult *match = [regex firstMatchInString:magicString options:0 range:NSMakeRange(0, magicString.length)];
Expand Down Expand Up @@ -52,13 +53,13 @@ + (instancetype)attributesForItemAtURL:(NSURL *)aURL {
// Private Methods
////////////////////////////////////////////////////////////////////////////////

+ (NSString *)magicStringForItemAtURL:(NSURL *)aURL {
+ (NSString *)magicStringForItemAtURL:(NSURL *)aURL usingLcALL:(NSString *)lcALL {
NSString *path = [aURL path];
NSParameterAssert(path);

NSMutableDictionary *environment =
[NSProcessInfo.processInfo.environment mutableCopy];
environment[@"LC_ALL"] = @"en_US.UTF-8";
environment[@"LC_ALL"] = lcALL;

NSTask *task = [NSTask new];
task.launchPath = @"/usr/bin/file";
Expand Down

0 comments on commit 171426b

Please sign in to comment.