We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bcf4855 commit afc6873Copy full SHA for afc6873
oneport/src/config.rs
@@ -52,7 +52,14 @@ async fn find_config(file: Option<String>) -> Option<String> {
52
Ok(v) => v,
53
_ => return None,
54
};
55
- let config = String::from_utf8(config).unwrap_or_default();
+ // BOM 编码的 UTF-8 字符串将从以下三个字节开始:EF BB BF
56
+ // 从文件/流中提取字符串时,必须忽略这些字节(如果存在)。
57
+ let config = if config[..3] == vec![0xEF, 0xBB, 0xBF] {
58
+ &config[3..]
59
+ } else {
60
+ &config
61
+ };
62
+ let config = String::from_utf8_lossy(config).to_string();
63
Some(config)
64
}
65
None => {
0 commit comments