“EF BB BF” at the beginning of JSON files created in Visual Studio

前端 未结 2 963
无人及你
无人及你 2021-01-04 08:03

I have a bunch of JSON files set as Embedded resource in one of my projects. I\'m using Newtonsoft.Json to parse these files:

2条回答
  •  时光取名叫无心
    2021-01-04 08:29

    That's a byte-order mark (BOM).

    I'm assuming your first code block is showing how you get the file. If you want the files in UTF-8 without a BOM, you can use the UTF8Encoding constructor to build an encoding instance without a BOM:

    var str = new UTF8Encoding(false).GetString(result);
    

提交回复
热议问题