Can generate the file without BOM?
See original GitHub issueSteps to reproduce
dotnet new xxx
Expected behavior
Generate the all file without BOM
Actual behavior
Generate the all file with BOM
Environment data
dotnet --info
output:
Product Information: Version: 2.1.104 Commit SHA-1 hash: 48ec687460
Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.104\
Microsoft .NET Core Shared Framework Host
Version : 2.0.6 Build : 74b1c703813c8910df5b96f304b0f2b78cdf194d
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:14 (10 by maintainers)
Top Results From Across the Web
How do I save file in UTF-8 without BOM
In the top menu select Encoding > Convert to UTF-8 (option without BOM); Save the file. That's it, you should now have a...
Read more >c# - Create Text File Without BOM
I'm stuck! My objective is create a file using UTF-8 as Encoding and 8859-1 as CharSet. Is this so hard to accomplish or...
Read more >Solved: Write a file in UTF-8 without BOM - SAS Communities
Solved: Hello, I am using the following code to write a text file; DATA _NULL_; SET HAVE; FILE 'pathofthefile/nameofthefile.txt'
Read more >Create file with UTF-8 without BOM - Help
I am trying a create a new file by Create File and Append Line activity. But the issue is it is creating a...
Read more >services Create file in UTF8 without BOM encoding
Hi, I had a requirement in which i am convrting the UTF-BOM bytes to string and from the string I need to convert...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW at least for C# to quote from the ECMA-334 5th Edition (https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-334.pdf):
7.1 Programs (PDF Page 35):
Nothing in here says that it has to contain the BOM, so if you are looking for the end all be all it will not be found in the standard…
That being said every Visual Studio version we have ever used the templates have always contained the BOM. We have commit hooks that enforce it for us internally due to some of the issues @sharwell as mentioned. For us there was a portion of code that contained some exotic characters required by a third party library that was garbled by text editors not properly respecting the fact that the file was indeed UTF-8. As he says having the BOM avoids more issues than it causes. YMMV.
❗️ Source files need to be generated with BOM. Otherwise, certain editors will treat them in non-uniform manner and eventually someone will accidentally save the file with question marks (encoding error fallback character). Normally I see this in author names in files getting messed up, but recently we found a curly quote in dotnet/winforms which was incorrectly saved. These errors are easy to miss and (in many cases) hard to fix, so we create the file with BOM to avoid it altogether.
We have a secondary benefit that the BOM triggers an early exit in the automatic encoding detection algorithm in .NET, so editors like Visual Studio load files faster. It’s a small win and not really significant compared to the problem above, but I find it interesting. 😄