Revision: 28947
          http://sourceforge.net/p/bibdesk/svn/28947
Author:   hofman
Date:     2024-09-06 12:37:59 +0000 (Fri, 06 Sep 2024)
Log Message:
-----------
NS encoding is 0 when invalid, not CF invalid

Modified Paths:
--------------
    trunk/bibdesk/BDSKAsynchronousWebParser.m
    trunk/bibdesk/BDSKDBLPGroupServer.m
    trunk/bibdesk/BDSKDOIParser.m
    trunk/bibdesk/BDSKMODSParser.m
    trunk/bibdesk/BDSKTextImportController.m
    trunk/bibdesk/BDSKWebGroup.m

Modified: trunk/bibdesk/BDSKAsynchronousWebParser.m
===================================================================
--- trunk/bibdesk/BDSKAsynchronousWebParser.m   2024-08-26 14:38:58 UTC (rev 
28946)
+++ trunk/bibdesk/BDSKAsynchronousWebParser.m   2024-09-06 12:37:59 UTC (rev 
28947)
@@ -205,7 +205,7 @@
     NSString *encodingName = [[download response] textEncodingName];
     NSStringEncoding encoding = [NSString 
encodingForIANACharSetName:encodingName];
     
-    if (encoding != kCFStringEncodingInvalidId)
+    if (encoding != 0)
         string = [[NSString alloc] initWithData:data encoding:encoding];
     if (nil == string && encoding != NSUTF8StringEncoding)
         string = [[NSString alloc] initWithData:data 
encoding:NSUTF8StringEncoding];

Modified: trunk/bibdesk/BDSKDBLPGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKDBLPGroupServer.m 2024-08-26 14:38:58 UTC (rev 28946)
+++ trunk/bibdesk/BDSKDBLPGroupServer.m 2024-09-06 12:37:59 UTC (rev 28947)
@@ -330,9 +330,7 @@
         if (i != NSNotFound) {
             isBibTeX = YES;
             NSString *encodingName = [response textEncodingName];
-            NSStringEncoding nsEncoding = [NSString 
encodingForIANACharSetName:encodingName];
-            if (nsEncoding == kCFStringEncodingInvalidId)
-                nsEncoding = NSUTF8StringEncoding;
+            NSStringEncoding nsEncoding = [NSString 
encodingForIANACharSetName:encodingName] ?: NSUTF8StringEncoding;
             NSString *btString = [[NSString alloc] initWithData:data 
encoding:nsEncoding];
             pubs = [BDSKBibTeXParser itemsFromString:btString owner:group 
error:NULL];
             [bibtexFetches replaceObjectAtIndex:i withObject:pubs];

Modified: trunk/bibdesk/BDSKDOIParser.m
===================================================================
--- trunk/bibdesk/BDSKDOIParser.m       2024-08-26 14:38:58 UTC (rev 28946)
+++ trunk/bibdesk/BDSKDOIParser.m       2024-09-06 12:37:59 UTC (rev 28947)
@@ -83,9 +83,7 @@
     BibItem *item = nil;
     if (data) {
         NSString *bibtexString = nil;
-        NSStringEncoding encoding = [NSString 
encodingForIANACharSetName:encodingName];
-        if (encoding == kCFStringEncodingInvalidId)
-            encoding = NSUTF8StringEncoding;
+        NSStringEncoding encoding = [NSString 
encodingForIANACharSetName:encodingName] ?: NSUTF8StringEncoding;
         bibtexString = [[[NSString alloc] initWithData:data encoding:encoding] 
stringByRemovingSurroundingWhitespace];
         if (bibtexString && [BDSKBibTeXParser canParseString:bibtexString]) {
             NSError *error = nil;

Modified: trunk/bibdesk/BDSKMODSParser.m
===================================================================
--- trunk/bibdesk/BDSKMODSParser.m      2024-08-26 14:38:58 UTC (rev 28946)
+++ trunk/bibdesk/BDSKMODSParser.m      2024-09-06 12:37:59 UTC (rev 28947)
@@ -73,9 +73,7 @@
     
     NSData *xmlData = [marcDoc XMLData];
     NSString *encodingName = [marcDoc characterEncoding];
-    NSStringEncoding encoding = [NSString 
encodingForIANACharSetName:encodingName];
-    if (encoding == kCFStringEncodingInvalidId)
-        encoding = NSUTF8StringEncoding;
+    NSStringEncoding encoding = [NSString 
encodingForIANACharSetName:encodingName] ?: NSUTF8StringEncoding;
     
     NSString *xmlString = [[NSString alloc] initWithData:xmlData 
encoding:encoding];
     NSArray *parsedItems = [BDSKMARCParser itemsFromMARCXMLString:xmlString 
error:outError];

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2024-08-26 14:38:58 UTC (rev 
28946)
+++ trunk/bibdesk/BDSKTextImportController.m    2024-09-06 12:37:59 UTC (rev 
28947)
@@ -1393,9 +1393,7 @@
         
         if(string == nil) {
             NSString *encodingName = [dataSource textEncodingName];
-            NSStringEncoding nsEncoding = [NSString 
encodingForIANACharSetName:encodingName];
-            if (nsEncoding == kCFStringEncodingInvalidId)
-                nsEncoding = NSUTF8StringEncoding;
+            NSStringEncoding nsEncoding = [NSString 
encodingForIANACharSetName:encodingName] ?: NSUTF8StringEncoding;
             string = [[NSString alloc] initWithData:[dataSource data] 
encoding:nsEncoding];
         }
         

Modified: trunk/bibdesk/BDSKWebGroup.m
===================================================================
--- trunk/bibdesk/BDSKWebGroup.m        2024-08-26 14:38:58 UTC (rev 28946)
+++ trunk/bibdesk/BDSKWebGroup.m        2024-09-06 12:37:59 UTC (rev 28947)
@@ -271,7 +271,7 @@
             if(string == nil) {
                 NSData *data = [dataSource data];
                 NSString *encodingName = [dataSource textEncodingName];
-                NSStringEncoding encoding = encodingName ? [NSString 
encodingForIANACharSetName:encodingName] : NSUTF8StringEncoding;
+                NSStringEncoding encoding = [NSString 
encodingForIANACharSetName:encodingName] ?: NSUTF8StringEncoding;
                 if (encoding != kCFStringEncodingInvalidId)
                     string = [[NSString alloc] initWithData:data 
encoding:encoding];
                 if (nil == string && encoding != NSUTF8StringEncoding)

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to