remove utf8 BOM from start of files

This commit is contained in:
Connor Skees 2020-08-18 06:12:57 -04:00
parent 6debd2ef52
commit b771befed4
2 changed files with 11 additions and 1 deletions

View File

@ -40,7 +40,7 @@ impl<'a> Iterator for Lexer<'a> {
impl<'a> Lexer<'a> {
pub fn new(file: &'a Arc<File>) -> 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,
}

View File

@ -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"
);