Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 555 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing hidden file end characters (BOM) in visual studio

#1
I'm using a batch file to concatenate 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've done this numerous times before on various projects, but this project uses .NET and the files are all being edited in visual studio.

The problem I have is that there are some mysterious hidden characters being added at the end of each file, which, when concatenated, causes the resulting css to be invalid.

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

All the individual CSS files validate and the errors are only thrown in the combined file at teh points were the individual files join.

Reply

#2
You probably want to use [YUICompressor .NET][1], instead of scripting this yourself.

[1]:

[To see links please register here]

Reply

#3
The problem is because of the byte order mark (BOM) in your files. The byte order mark is for unicode files to tell the processor the order of the bytes. You can read more about it here:

[To see links please register here]


The problem is that Visual Studio is adding those marks to your css file and when you combine them by concatenation, BOMs are ending up in the middle of the text, screwing things up.

When you go to the Save As dialog, you can expand the Save button to see the 'Save with Encoding' option. This will prompt you for a different encoding, and I think one of the Unicode options will leave out the BOM (somewhere in the list is UTF-8 without signature).

I don't know how to set Visual Studio to use a specific encoding by default.

To skirt the issues I created a program to concatenate files that would respect the BOM. I use that rather than copy, or the unix cat.
Reply

#4
[I wrote a nifty little command line program][1] that combines all files (i.e. css, etc) in a directory and removes the BOM (byte order mark) for you. It's about 5 lines of code and uses cssmin.js to handle the minification for you. There's also an example of how it looks in a Visual Studio post build event. Check it o


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through