summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-02 17:08:11 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-02 17:08:11 +0100
commitc24798d1ab4bb75c8ee0c8b8663b11e599df1c25 (patch)
treee7bf4102100af9685aa28f79ae5581e38296c18c /src/util.cc
parent7910e19cf145cbdc99fbf1015add6f8eb792e160 (diff)
Remove unicode BOM from SSA files.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 5510d8e..a736a91 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -65,3 +65,18 @@ sub::get_line_file (FILE* f)
return string (buffer);
}
+
+void
+sub::remove_unicode_bom (optional<string>& line)
+{
+ if (
+ line->length() >= 3 &&
+ static_cast<unsigned char> (line.get()[0]) == 0xef &&
+ static_cast<unsigned char> (line.get()[1]) == 0xbb &&
+ static_cast<unsigned char> (line.get()[2]) == 0xbf
+ ) {
+
+ /* Skip Unicode byte order mark */
+ line = line->substr (3);
+ }
+}