BomSquad; library to detect byte-order marks in files

BomSquad is a small utility for detecting byte-order marks in files. This often proves useful when using Java utilities, which tend to deal with BOMs very badly. I’ve been bitten with both JSCover and ANTLR, both of  which are excellent utilities, but which are written in Java and so can choke on some perfectly good input files. 

At the moment, it’s just a straight bit of code you can use to detect if a file has a BOM, and what kind of encoding is implied;

Use it like this;

var dog = new BomSquad.SnifferDog();
// eg, true
var hasBom = dog.DetectBom(filePath);
// eg "UTF-16 (LE)"
var bomType = dog.DetectBomType(filePath);

It is available through pre-release nuget package at https://www.nuget.org/packages/BomSquad/. Original source at https://github.com/stevecooperorg/BomSquad/.

Soon, I’ll add an MSBuild task, so you can automatically check your files as part of a build. This will help you never check in a broken file.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s