Dieser Artikel ist derzeit nur auf Englisch verfügbar.

Input is not proper UTF-8, indicate encoding: fix your XML feed

FeedAwake 4 Min. Lesezeit

The feed says it is UTF-8 (or says nothing, which for XML means the same), but somewhere in it there are bytes that aren't valid UTF-8. The parser can't guess what they were meant to be, so it stops, and Google Merchant Center, Meta and other channels can't read the feed.

It's almost always a few products, not the whole file: names with é, ü or ø, curly quotes, a € sign or a dash that came from somewhere other than the rest of the catalogue.

What the error looks like

PHP, xmllint:  Input is not proper UTF-8, indicate encoding !
               Bytes: 0xE9 0x20 0x63 0x72
Chrome, Edge:  error on line 5 at column 8: Encoding error
Firefox:       XML Parsing Error: not well-formed
Python:        not well-formed (invalid token): line 5, column 10

The full libxml2 message, the one PHP servers and many feed tools show, is the most useful, because of its second line.

Read the Bytes line

Bytes: 0xE9 0x20 0x63 0x72 are the bytes at the error position. The first one is the problem. In UTF-8, every byte from 0x80 up belongs to a multi-byte sequence, so a lone 0xE9 followed by a space (0x20) is invalid. In Windows-1252 and ISO-8859-1, the encodings old systems and Excel use, it's simply é.

The first byte usually tells you what the character was:

Byte Windows-1252 Byte Windows-1252
0x80 € 0xAE ®
0x92 ’ 0xB0 °
0x93 / 0x94 “ ” 0xE4 / 0xF6 / 0xFC ä ö ü
0x96 / 0x97 – — 0xE9 / 0xE8 é è
0x99 ™ 0xE5 / 0xF8 å ø
0xA0 non-breaking space 0xDF ß

If the first byte is between 0xC2 and 0xF4 and the next one is a normal character like < (0x3C), the text was cut in the middle of a character. See cause 3 below.

Find every broken product, not just the first

The parser stops at the first bad byte, but there are usually more. On Linux or macOS this lists every line with invalid UTF-8:

LC_ALL=C.UTF-8 grep -naxv '.*' feed.xml

The lines it prints show the broken characters as �. To check that a file is clean, iconv -f UTF-8 -t UTF-8 feed.xml > /dev/null prints nothing for a valid file and "illegal input sequence at position …" otherwise. From each line, scroll up to the product's <g:id> to know what to fix in the shop.

The free feed checker shows the first errors with line and column without downloading the file. If the feed is on one line, see how to find the broken line.

The four usual causes

1. Products imported from Excel or an old system

The catalogue is UTF-8, but some products came in through a CSV that was saved in Excel's default "CSV (Comma delimited)" format on Windows, which uses Windows-1252. Their text went into the database byte for byte and from there into the feed. Excel's "CSV UTF-8" option avoids it for future imports. Products already imported need their text converted or re-imported.

2. A database connection with the wrong character set

The data is stored correctly, but the export connects with a different charset (for example latin1 instead of utf8mb4 in MySQL), so text arrives converted to something else. Set the connection charset explicitly in the export script.

3. Text cut by bytes, not characters

Input is not proper UTF-8, indicate encoding !
Bytes: 0xC3 0x3C 0x2F 0x74

0xC3 starts a two-byte character, and 0x3C is <: the closing tag came right after half a character. A script shortened the title or description with a byte-based function (substr in PHP) and cut é in half. That's why the error sits right before a closing tag. Use a character-based function (mb_substr).

4. The whole file in another encoding

If every non-English character in the file is wrong, the export isn't producing UTF-8 at all. Changing the declaration to encoding="ISO-8859-1" only helps if the entire file really is in that encoding, which is rarely true once products come from more than one source. Make the export write UTF-8 end to end.

The silent opposite

The reverse mistake doesn't produce an error. A UTF-8 file declared as ISO-8859-1 parses fine, and Café turns into Café in your product titles. If you see é, ’ or ü in Merchant Center, check the declaration and the export settings the same way.

Keep it from coming back

Encoding errors arrive with new data, not with code changes: one supplier file or one CSV import is enough. FeedAwake checks the feed on a schedule and alerts you by email, Telegram, Slack or Discord when it stops parsing, with the line and message, so a bad import is found the same day. To check it once, use the free feed checker.

Produktfeed kostenlos prüfen

Finden Sie Feed-Fehler, bevor sie Werbebudget kosten. Kein Konto erforderlich.

14 Tage kostenlos testen Kostenloser Merchant Center Audit

Weitere Artikel