From a002558d5e096d91c3c4294e30405ad3bce3e5d6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 14 Jun 2015 18:55:52 +0100 Subject: Skip Unicode BOM at the start of subrip files. --- src/subrip_reader.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/subrip_reader.cc') diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index 5e9e010..3f1c23d 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -54,6 +54,17 @@ SubripReader::SubripReader (FILE* f) line = string (buffer); trim_right_if (line, boost::is_any_of ("\n\r")); + if ( + line.length() >= 3 && + static_cast (line[0]) == 0xef && + static_cast (line[1]) == 0xbb && + static_cast (line[2]) == 0xbf + ) { + + /* Skip Unicode byte order mark */ + line = line.substr (3); + } + switch (state) { case COUNTER: { -- cgit v1.2.3