From 56b8c86aaccedaf3824fc01c92230c35e37fa642 Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Sat, 12 Nov 2011 18:17:38 -0500 Subject: [PATCH] update UTI info; try to support multiple encodings --- .../project.pbxproj | 3 ++ .../GeneratePreviewForURL.m | 15 +++++++-- .../MultiMarkdown QuickLook-Info.plist | 32 +++++++++---------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/MultiMarkdown QuickLook.xcodeproj/project.pbxproj b/MultiMarkdown QuickLook.xcodeproj/project.pbxproj index 86991dd..16e6978 100644 --- a/MultiMarkdown QuickLook.xcodeproj/project.pbxproj +++ b/MultiMarkdown QuickLook.xcodeproj/project.pbxproj @@ -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; diff --git a/MultiMarkdown QuickLook/GeneratePreviewForURL.m b/MultiMarkdown QuickLook/GeneratePreviewForURL.m index 6205fd6..c96b188 100644 --- a/MultiMarkdown QuickLook/GeneratePreviewForURL.m +++ b/MultiMarkdown QuickLook/GeneratePreviewForURL.m @@ -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) @@ -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]]; diff --git a/MultiMarkdown QuickLook/MultiMarkdown QuickLook-Info.plist b/MultiMarkdown QuickLook/MultiMarkdown QuickLook-Info.plist index acc5a0e..7cadf50 100644 --- a/MultiMarkdown QuickLook/MultiMarkdown QuickLook-Info.plist +++ b/MultiMarkdown QuickLook/MultiMarkdown QuickLook-Info.plist @@ -18,10 +18,10 @@ LSItemContentTypes net.daringfireball.markdown - com.multimarkdown.text + net.multimarkdown.text org.vim.markdown-file public.opml - com.multimarkdown.opml + net.multimarkdown.opml org.opml.opml @@ -56,6 +56,20 @@ 12B11958-4455-4E27-9FAA-A8E5F7E22211 + CFPlugInUnloadFunction + + NSHumanReadableCopyright + Copyright © 2011 Fletcher T. Penney. All rights reserved. + QLNeedsToBeRunInMainThread + + QLPreviewHeight + 600 + QLPreviewWidth + 800 + QLSupportsConcurrentRequests + + QLThumbnailMinimumSize + 17 UTImportedTypeDeclarations @@ -75,19 +89,5 @@ - CFPlugInUnloadFunction - - NSHumanReadableCopyright - Copyright © 2011 Fletcher T. Penney. All rights reserved. - QLNeedsToBeRunInMainThread - - QLPreviewHeight - 600 - QLPreviewWidth - 800 - QLSupportsConcurrentRequests - - QLThumbnailMinimumSize - 17