diff --git a/src/lexer.rs b/src/lexer.rs index 858a197..cc762d4 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -40,7 +40,7 @@ impl<'a> Iterator for Lexer<'a> { impl<'a> Lexer<'a> { pub fn new(file: &'a Arc) -> Lexer<'a> { Lexer { - buf: file.source().chars().peekable(), + buf: file.source().trim_start_matches("\u{ef}\u{bb}\u{bf}").trim_start_matches("\u{feff}").chars().peekable(), pos: 0, file, } diff --git a/tests/misc.rs b/tests/misc.rs index c9c68c5..1b66ac7 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -96,3 +96,13 @@ test!( "a {\n a: b\n}\n\nb {}\n", "a {\n a: b;\n}\n" ); +test!( + file_begins_with_utf8_bom, + "\u{feff}a {\n color: red\n}\n", + "a {\n color: red;\n}\n" +); +test!( + file_begins_with_bom, + "\u{ef}\u{bb}\u{bf}a {\n color: red\n}\n", + "a {\n color: red;\n}\n" +);