From fa7bc921f3fdf492dd8742bb5b778c7e4b38d98f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 6 Feb 2018 20:03:59 +0000 Subject: Fix failure to parse subtitle files with OS X line endings. --- src/lib/text_subtitle.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/lib') diff --git a/src/lib/text_subtitle.cc b/src/lib/text_subtitle.cc index 2de815459..a3c3975e4 100644 --- a/src/lib/text_subtitle.cc +++ b/src/lib/text_subtitle.cc @@ -43,6 +43,13 @@ TextSubtitle::TextSubtitle (shared_ptr content) { Data in (content->path (0)); + /* Fix OS X line endings */ + for (int i = 0; i < in.size(); ++i) { + if (in.data()[i] == '\r' && ((i == in.size() - 1) || in.data()[i + 1] != '\n')) { + in.data()[i] = '\n'; + } + } + UErrorCode status = U_ZERO_ERROR; UCharsetDetector* detector = ucsdet_open (&status); ucsdet_setText (detector, reinterpret_cast (in.data().get()), in.size(), &status); -- cgit v1.2.3