UTF-8 without BOM

前端 未结 10 1771
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 15:31

I have javascript files that I need them to be saved in UTF-8 (without BOM), every time I convert them to the correct format in Notepad++, they are reverted back to

相关标签:
10条回答
  • 2020-11-22 15:54

    Recently I found this tiny command-line tool which adds or removes the BOM on arbitary UTF-8 encoded files: UTF BOM Utils (new link at github)

    Little drawback, you can download only the plain C++ source code. You have to create the makefile (with CMake, for example) and compile it by yourself, binaries are not provided on this page. However, for a software developer this should not be any issue.

    0 讨论(0)
  • 2020-11-22 15:56

    I've created the Fix File Encoding extension that prevents Visual Studio 2010+ from adding BOM to UTF-8 files.

    0 讨论(0)
  • 2020-11-22 15:57

    Unfortunately this does not work with csproj files. There is no "Advanced save option" and even though you have set it to "UTF-8 without signature" for a cs file, csproj files still are saved with BOM. If you use VSS it still complains about project files.

    0 讨论(0)
  • 2020-11-22 16:01

    BOM or Byte Order Mark is sometimes quite annoying. Visual Studio does not change the file unless you save it (as Hans said).

    And here is the solution to your problem: If you want to save a file with other encodings select save as and extend the save button in file dialog and select "Save with encoding". Or if you you want to get rid of this setting permanently just open File menu and select "Advanced save options" and there you should select "UTF-8 without signature" (and that also answered your last question :). Yes "UTF-8 without signature" is same as without BOM.

    0 讨论(0)
提交回复
热议问题