Detects the most likely encoding of a byte block. Priority: explicit BOM → valid UTF-8 → pure ASCII → Latin-1 → binary.
Not infallible — it's a quick heuristic for the inspector. For production use a dedicated library (chardet, jschardet).
Byte block to analyze (doesn't need to be the whole file)
DetectedEncoding with detected encoding, whether there's a BOM, and where content starts
Detects the most likely encoding of a byte block. Priority: explicit BOM → valid UTF-8 → pure ASCII → Latin-1 → binary.
Not infallible — it's a quick heuristic for the inspector. For production use a dedicated library (chardet, jschardet).