Removing hidden end characters (BOMs) in visual studio

I use a batch file to merge all my css files

copy /b reset.css+action-plan.css+buttons.css+behaviours.css+footer.css+forms.css+header.css+home.css+layout.css+lightbox.css+print.css+questionnaire.css+typography.css+you-told-us.css main.css 

I did this many times before in different projects, but .NET is used in this project, and all files are edited in the visual studio.

The problem is that at the end of each file, some mysterious hidden characters are added, which, when combined, result in the resulting css being invalid.

  126 BLOCKQUOTE, Q Lexical error at line 119, column 1.
  Encountered: "?"  (63), after: "" ???  / **** left column **** / 

All individual CSS files are checked, and errors are set only in the combined file at the points where the individual files are attached.

+4
source share
3 answers

The problem is that your byte (BOM) is marked in your files. The byte order icon is for Unicode files to tell the processor the byte order. You can read about it here:

http://en.wikipedia.org/wiki/Byte_order_mark

The problem is that Visual Studio adds these labels to your css file, and when you combine them by concatenating, the specifications end in the middle of the text, twisting things.

When you go to the Save As dialog box, you can open the Save button to see Save With Encoding. This will offer you a different encoding, and I think that one of the Unicode parameters will not contain the specification (somewhere in the list there is UTF-8 without a signature).

I do not know how to install Visual Studio to use a specific encoding by default.

To get around the problems, I created a program to concatenate files that will respect the specification. I use this, not a copy, or a unix cat.

+5
source

You probably want to use YUICompressor.NET instead of creating scripts yourself.

0
source

I wrote a small small command line program that combines all the files (i.e. css, etc.) in a directory and removes the specification (byte order of character) for you. This is about 5 lines of code and uses cssmin.js to handle the minimum for you. There's also an example of how it looks in the Visual Studio post-build event. Check it out o

-1
source

All Articles