[vlc-devel] [PATCH] Fix subtitle downloads by not messing encodings
Filipe Cabecinhas
vlc at filcab.net
Sun Jan 18 21:19:11 CET 2015
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.
---
Sources/VLCOpenNetworkStreamViewController.m | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Sources/VLCOpenNetworkStreamViewController.m b/Sources/VLCOpenNetworkStreamViewController.m
index 9038180..2969cb0 100644
--- a/Sources/VLCOpenNetworkStreamViewController.m
+++ b/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;
}
}
--
1.9.3 (Apple Git-50)
More information about the vlc-devel
mailing list