I've got UTF-8 encoded data that begins with the UTF-8 Byte Order Mark (0xef, 0xbb, 0xbf). I would expect that when I hand that to String::from_utf8
the BOM would just be dropped, but instead it gets changed to " \u{feff}":
let x: Vec<u8> = vec![0xef, 0xbb, 0xbf, 0x7b];
let y = String::from_utf8(x);
// Would expect Ok("{"), get Ok("\u{feff}{")
println!("{:#?}", y);
Of course, I can just check for the BOM & remove it before I call from_utf8
, but I'm wondering if this is expected?