From 105b0f26bbd6b4e2be418b8552cdcbb979374060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Sat, 19 Oct 2019 18:17:34 +0200 Subject: [PATCH] Improve file encoding detection. --- Plugins/CueSheet/CueSheet.m | 4 ++++ Plugins/M3u/M3uContainer.m | 5 +++++ Plugins/Pls/PlsContainer.m | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/Plugins/CueSheet/CueSheet.m b/Plugins/CueSheet/CueSheet.m index 77e39817f..9a37cd612 100644 --- a/Plugins/CueSheet/CueSheet.m +++ b/Plugins/CueSheet/CueSheet.m @@ -72,6 +72,10 @@ error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; } + if (error) { + error = nil; + contents = [NSString stringWithContentsOfFile:filename encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:&error]; + } if (error) { error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error]; diff --git a/Plugins/M3u/M3uContainer.m b/Plugins/M3u/M3uContainer.m index 0028c9189..21d390a17 100644 --- a/Plugins/M3u/M3uContainer.m +++ b/Plugins/M3u/M3uContainer.m @@ -83,6 +83,11 @@ error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; } + if (error) { + DLog(@"Trying windows GB 18030 2000"); + error = nil; + contents = [NSString stringWithContentsOfFile:filename encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:&error]; + } if (error) { DLog(@"Trying windows CP1251"); error = nil; diff --git a/Plugins/Pls/PlsContainer.m b/Plugins/Pls/PlsContainer.m index c027ea72a..0c8ad126b 100644 --- a/Plugins/Pls/PlsContainer.m +++ b/Plugins/Pls/PlsContainer.m @@ -85,6 +85,11 @@ error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; } + if (error) { + DLog(@"Trying windows GB 18030 2000"); + error = nil; + contents = [NSString stringWithContentsOfFile:filename encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:&error]; + } if (error) { DLog(@"Trying windows CP1251"); error = nil;