Skip to content

Do not show encoding error when file only contains BOM

Jan Paul Batrina requested to merge work/fix-BOM-encoding-error into master

failedToConvertOnce shouldn't be set to true when the BOM was processed.

After this commit, opening files with the following hex content should open in the corresponding encodings:

Content Encoding Sample file
E9 Latin-1/ISO-8859-15 bug_272579é.txt
EF BB BF UTF-8 bug_440359BOM.txt
EF BB BF E9 FF Latin-1/ISO-8859-15 bug_440359BOMéÿ.txt

Then forcing the Latin-1 files above to be opened as UTF-8 should show the "invalid encoding" error message properly.

Before:

kate-BOM-encodingerror-before

After:

kate-BOM-encodingerror-after

BUG: 440359 CCBUG: 272579

I also tested with UTF-16 and UTF-32 BOMs, and they also have the same issue (which is fixed with this patch).

I'm not 100% sure if this is the appropriate fix, but this is the most minimally invasive patch I can think of.

Edited by Jan Paul Batrina

Merge request reports