summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorNaim A <227396+naim94a@users.noreply.github.com>2023-05-29 21:13:11 +0300
committerGitHub <noreply@github.com>2023-05-29 20:13:11 +0200
commit6db4c39cd98631dd621d05120638d1b3e5f73ce0 (patch)
treee31be413845ff1b781575d988414015d9ad57633 /cli
parenteab267bef081e6058055715555156e119ce9c086 (diff)
ignore utf-8 bom (#1317)
Diffstat (limited to 'cli')
-rw-r--r--cli/src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 9b771163..09ba0515 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -557,7 +557,13 @@ impl World for SystemWorld {
.source
.get_or_init(|| {
let buf = read(path)?;
- let text = String::from_utf8(buf)?;
+ let text = if buf.starts_with(b"\xef\xbb\xbf") {
+ // remove UTF-8 BOM
+ std::str::from_utf8(&buf[3..])?.to_owned()
+ } else {
+ // Assume UTF-8
+ String::from_utf8(buf)?
+ };
Ok(self.insert(path, text))
})
.clone()