Skip to content

Commit

Permalink
update UTI info; try to support multiple encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcher committed Nov 12, 2011
1 parent 2851fff commit 56b8c86
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
3 changes: 3 additions & 0 deletions MultiMarkdown QuickLook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
/* Begin PBXProject section */
5A7859C31443BDBB00C7C824 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0420;
};
buildConfigurationList = 5A7859C61443BDBB00C7C824 /* Build configuration list for PBXProject "MultiMarkdown QuickLook" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
Expand Down
15 changes: 13 additions & 2 deletions MultiMarkdown QuickLook/GeneratePreviewForURL.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NSData* processMMD(NSURL* url);
NSData* processOPML2MMD(NSURL* url);

BOOL logDebug = YES;
BOOL logDebug = NO;


OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
Expand Down Expand Up @@ -112,7 +112,18 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,

[task launch];

NSString *theData = [NSString stringWithContentsOfFile:[url path] encoding:NSUTF8StringEncoding error:nil];
NSStringEncoding encoding = 0;

// Ensure we used proper encoding - try different options until we get a hit
// if (plainText == nil)
// plainText = [NSString stringWithContentsOfFile:[url path] usedEncoding:<#(NSStringEncoding *)#> error:<#(NSError **)#> encoding:NSASCIIStringEncoding];



NSString *theData = [NSString stringWithContentsOfFile:[url path] usedEncoding:&encoding error:nil];

if (logDebug)
NSLog(@"Used %lu encoding",(unsigned long) encoding);

[writeHandle writeData:[theData dataUsingEncoding:NSUTF8StringEncoding]];

Expand Down
32 changes: 16 additions & 16 deletions MultiMarkdown QuickLook/MultiMarkdown QuickLook-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<key>LSItemContentTypes</key>
<array>
<string>net.daringfireball.markdown</string>
<string>com.multimarkdown.text</string>
<string>net.multimarkdown.text</string>
<string>org.vim.markdown-file</string>
<string>public.opml</string>
<string>com.multimarkdown.opml</string>
<string>net.multimarkdown.opml</string>
<string>org.opml.opml</string>
</array>
</dict>
Expand Down Expand Up @@ -56,6 +56,20 @@
<string>12B11958-4455-4E27-9FAA-A8E5F7E22211</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2011 Fletcher T. Penney. All rights reserved.</string>
<key>QLNeedsToBeRunInMainThread</key>
<false/>
<key>QLPreviewHeight</key>
<real>600</real>
<key>QLPreviewWidth</key>
<real>800</real>
<key>QLSupportsConcurrentRequests</key>
<false/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
Expand All @@ -75,19 +89,5 @@
</dict>
</dict>
</array>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2011 Fletcher T. Penney. All rights reserved.</string>
<key>QLNeedsToBeRunInMainThread</key>
<false/>
<key>QLPreviewHeight</key>
<real>600</real>
<key>QLPreviewWidth</key>
<real>800</real>
<key>QLSupportsConcurrentRequests</key>
<false/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
</dict>
</plist>

0 comments on commit 56b8c86

Please sign in to comment.