Invalid bytes in character encoding

The file is not in the encoding it claims (UTF-8 unless it says otherwise).

The message, as the validator reports it
Invalid bytes in character encoding

Why it happens

  • A file saved as Windows-1252, ISO-8859-1 or Windows-1251 without an encoding in the XML declaration, so it is read as UTF-8.
  • An encoding declaration that does not match how the file was actually saved.
  • Text in two encodings in one file, after joining files or pasting.

How to fix it

Either convert the file to UTF-8, or declare its real encoding: <?xml version="1.0" encoding="windows-1252"?>. The validator reads the common single-byte encodings when they are declared.

Example

Reports the error
<note>café</note>
Fixed
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>café</note>