We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0680a28 commit 588bd66Copy full SHA for 588bd66
src/file/source/file.rs
@@ -115,7 +115,17 @@ where
115
.unwrap_or_else(|| filename.clone());
116
117
// Read contents from file
118
- let text = fs::read_to_string(filename)?;
+ let buf = fs::read(filename)?;
119
+
120
+ // If it exists, skip the UTF-8 BOM byte sequence: EF BB BF
121
+ let buf = if buf.len() >= 3 && &buf[0..3] == b"\xef\xbb\xbf" {
122
+ &buf[3..]
123
+ } else {
124
+ &buf
125
+ };
126
127
+ let c = String::from_utf8_lossy(buf);
128
+ let text = c.into_owned();
129
130
Ok(FileSourceResult {
131
uri: Some(uri.to_string_lossy().into_owned()),
0 commit comments