Переглянути джерело

Fix subtitle downloads by not messing encodings

VLC was downloading subtitle files as an NSString and assumed certain
encodings. This is useless to do in the controller, because VLCKit will,
eventually, autodetect encodings and “do the right thing”.

Because of this, some subtitle files (e.g: UTF-16 encoded ones) wouldn't
work over the network, but would work if copied to the device.

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Filipe Cabecinhas 10 роки тому
батько
коміт
dd7bcb2b11
1 змінених файлів з 2 додано та 2 видалено
  1. 2 2
      Sources/VLCOpenNetworkStreamViewController.m

+ 2 - 2
Sources/VLCOpenNetworkStreamViewController.m

@@ -283,7 +283,7 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
         NSInteger httpStatus = [(NSHTTPURLResponse *)response statusCode];
 
         if (httpStatus == 200) {
-            NSString *receivedSub = [NSString stringWithContentsOfURL:checkURL encoding:NSASCIIStringEncoding error:nil];
+            NSData *receivedSub = [NSData dataWithContentsOfURL:checkURL];
 
             NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
             NSString *directoryPath = searchPaths[0];
@@ -297,7 +297,7 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
                     APLog(@"file creation failed, no data was saved");
             }
 
-            [receivedSub writeToFile:fileSubtitlePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
+            [receivedSub writeToFile:fileSubtitlePath atomically:YES];
             return fileSubtitlePath;
         }
     }