}
trim (*line);
+ remove_unicode_bom (line);
if (starts_with (*line, ";") || line->empty ()) {
continue;
}
trim_right_if (*line, boost::is_any_of ("\n\r"));
-
- 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);
- }
+ remove_unicode_bom (line);
switch (state) {
case COUNTER:
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);
+ }
+}
namespace sub {
extern bool empty_or_white_space (std::string s);
+extern void remove_unicode_bom (boost::optional<std::string>& line);
extern boost::optional<std::string> get_line_stringstream (std::stringstream* str);
extern boost::optional<std::string> get_line_file (FILE* f);
}
-
-