Revision: 21974
          http://sourceforge.net/p/bibdesk/svn/21974
Author:   hofman
Date:     2018-02-19 23:00:32 +0000 (Mon, 19 Feb 2018)
Log Message:
-----------
smarter tries for encoding

Modified Paths:
--------------
    trunk/bibdesk/BDSKWebGroup.m

Modified: trunk/bibdesk/BDSKWebGroup.m
===================================================================
--- trunk/bibdesk/BDSKWebGroup.m        2018-02-19 22:55:57 UTC (rev 21973)
+++ trunk/bibdesk/BDSKWebGroup.m        2018-02-19 23:00:32 UTC (rev 21974)
@@ -254,15 +254,18 @@
         if ([MIMEType isEqualToString:@"text/plain"] || [MIMEType 
isEqualToString:@"application/x-bibdesk"] || [MIMEType 
isEqualToString:@"application/x-research-info-systems"] || [MIMEType 
isEqualToString:@"application/x-endnote-refer"]) {
             NSString *string = [[dataSource representation] documentSource];
             if(string == nil) {
+                NSData *data = [dataSource data];
                 NSString *encodingName = [dataSource textEncodingName];
-                CFStringEncoding cfEncoding = kCFStringEncodingInvalidId;
-                NSStringEncoding nsEncoding = NSUTF8StringEncoding;
-                
-                if (encodingName != nil)
-                    cfEncoding = 
CFStringConvertIANACharSetNameToEncoding((CFStringRef)encodingName);
-                if (cfEncoding != kCFStringEncodingInvalidId)
-                    nsEncoding = 
CFStringConvertEncodingToNSStringEncoding(cfEncoding);
-                string = [[[NSString alloc] initWithData:[dataSource data] 
encoding:nsEncoding] autorelease];
+                NSStringEncoding encoding = NSUTF8StringEncoding;
+                if (nil != encodingName)
+                    encoding = 
CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encodingName));
+                if (encoding != kCFStringEncodingInvalidId)
+                    string = [[NSString alloc] initWithData:data 
encoding:encoding];
+                if (nil == string && encoding != NSUTF8StringEncoding)
+                    string = [[NSString alloc] initWithData:data 
encoding:NSUTF8StringEncoding];
+                if (nil == string && encoding != NSISOLatin1StringEncoding)
+                    string = [[NSString alloc] initWithData:data 
encoding:NSISOLatin1StringEncoding];
+                [string autorelease];
             }
             BDSKStringType type = [string contentStringType];
             if (type == BDSKStringTypeBibTeX)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to