From ba7aaec69c2470cc2f085fbab477452d142c2e36 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 9 Mar 2021 23:49:13 -0800 Subject: [PATCH] M3U and PLS playlist handlers now correctly handle macOS Classic line endings --- Plugins/M3u/M3uContainer.m | 10 ++++++++++ Plugins/Pls/PlsContainer.m | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Plugins/M3u/M3uContainer.m b/Plugins/M3u/M3uContainer.m index 5fde70f3b..4f77d0301 100644 --- a/Plugins/M3u/M3uContainer.m +++ b/Plugins/M3u/M3uContainer.m @@ -92,6 +92,16 @@ filecontents[size] = '\0'; } + + // Handle macOS Classic and Windows line endings + { + char * contentsscan = filecontents; + while (*contentsscan) { + if (*contentsscan == '\r') + *contentsscan = '\n'; + ++contentsscan; + } + } DLog(@"Trying UTF8"); NSStringEncoding encoding = NSUTF8StringEncoding; diff --git a/Plugins/Pls/PlsContainer.m b/Plugins/Pls/PlsContainer.m index 527d603c8..4897a8c10 100644 --- a/Plugins/Pls/PlsContainer.m +++ b/Plugins/Pls/PlsContainer.m @@ -95,6 +95,16 @@ filecontents[size] = '\0'; } + // Handle macOS Classic and Windows line endings + { + char * contentsscan = filecontents; + while (*contentsscan) { + if (*contentsscan == '\r') + *contentsscan = '\n'; + ++contentsscan; + } + } + DLog(@"Trying UTF8"); NSStringEncoding encoding = NSUTF8StringEncoding; NSString *contents = [NSString stringWithCString:filecontents encoding:encoding];