UTF8Reader decoded non-BOM input strictly as UTF-8, so a byte that was not
valid UTF-8 became the replacement character U+FFFD. Playlists and lyrics
saved by Windows editors are commonly Windows-1252/Latin-1, where accented
characters are single high bytes (for example é as 0xE9). Those bytes were
mangled into U+FFFD, so an M3U entry like 'PokéMon' no longer matched the
scanned library path and the track was silently skipped, while pure-ASCII
entries in the same playlist imported fine.
UTF8Reader now keeps valid UTF-8 untouched and decodes any invalid byte as
Windows-1252 (a superset of Latin-1), recovering the accented characters
instead of losing them. BOM handling and UTF-16 transcoding are unchanged.
Closes#6037
Signed-off-by: Steve <stevejason639@gmail.com>
* fix: handle UTF-8 BOM in lyrics and playlist files
Added UTF-8 BOM (Byte Order Mark) detection and stripping for external lyrics files and playlist files. This ensures that files with BOM markers are correctly parsed and recognized as synced lyrics or valid playlists.
The fix introduces a new ioutils package with UTF8Reader and UTF8ReadFile functions that automatically detect and remove UTF-8, UTF-16 LE, and UTF-16 BE BOMs. These utilities are now used when reading external lyrics and playlist files to ensure consistent parsing regardless of BOM presence.
Added comprehensive tests for BOM handling in both lyrics and playlists, including test fixtures with actual BOM markers to verify correct behavior.
* test: add test for UTF-16 LE encoded LRC files
Signed-off-by: Deluan <deluan@navidrome.org>
---------
Signed-off-by: Deluan <deluan@navidrome.org>