From 65d9eb6f7e01e298ed52db0c2fb2bd7a8b48ecbd Mon Sep 17 00:00:00 2001 From: FrankHB Date: Sat, 25 Jul 2020 13:02:44 +0800 Subject: [PATCH] Handled UTF-8 BOM Fixed #1155 . --- src/book/book.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/book/book.rs b/src/book/book.rs index 071d1589..369c6a07 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -264,6 +264,10 @@ fn load_chapter>( 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 .strip_prefix(&src_dir) .expect("Chapters are always inside a book");