summaryrefslogtreecommitdiff
path: root/src/subrip_reader.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-14 18:55:52 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-14 18:55:52 +0100
commita002558d5e096d91c3c4294e30405ad3bce3e5d6 (patch)
tree35ac26bb2ef7190d832e5ad4386329c456d3902c /src/subrip_reader.cc
parent7ef8532e4402ad6596f3c92e25994c86ee9efbe9 (diff)
Skip Unicode BOM at the start of subrip files.
Diffstat (limited to 'src/subrip_reader.cc')
-rw-r--r--src/subrip_reader.cc11
1 files changed, 11 insertions, 0 deletions
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<unsigned char> (line[0]) == 0xef &&
+ static_cast<unsigned char> (line[1]) == 0xbb &&
+ static_cast<unsigned char> (line[2]) == 0xbf
+ ) {
+
+ /* Skip Unicode byte order mark */
+ line = line.substr (3);
+ }
+
switch (state) {
case COUNTER:
{