Diagnosing XML Encoding Mismatches: BOMs, Declarations, and Bad Bytes
XML parse failures and mojibake usually mean the BOM, the encoding declaration, and the actual bytes disagree. A diagnostic guide: detection order, a cause table, ordered checks, and matched fixes.