Byte-level evidence
Encoding belongs to the stored bytes, so the detector works from the selected file rather than from text already decoded by an editor. Explicit signatures, such as a byte order mark, can provide strong evidence. Without a signature, recurring byte patterns and whether sequences are valid under candidate character sets help distinguish likely interpretations.