Handled UTF-8 BOM

Fixed #1155 .
This commit is contained in:
FrankHB 2020-07-25 13:02:44 +08:00 committed by GitHub
parent 303db0ddec
commit 65d9eb6f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -264,6 +264,10 @@ fn load_chapter<P: AsRef<Path>>(
format!("Unable to read \"{}\" ({})", link.name, location.display()) format!("Unable to read \"{}\" ({})", link.name, location.display())
})?; })?;
if content.as_bytes().starts_with(b"\xef\xbb\xbf") {
content = content[3..].to_string()
}
let stripped = location let stripped = location
.strip_prefix(&src_dir) .strip_prefix(&src_dir)
.expect("Chapters are always inside a book"); .expect("Chapters are always inside a book");