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.