Decode downloaded subtitles to UTF-8 #212
Notifications
Due Date
No due date set.
Blocks
Reference: yolo/arr#212
Reference in New Issue
Block a user
Provider::downloadreturnsFetched.contentasVec<u8>— raw bytes,deliberately, because providers serve Latin-1 and Windows-1252 files and
guessing wrong at the provider boundary is worse than handing the bytes on
(#184).
arr_subs::srt::parsedeliberately takes&str(#190).Nothing in the milestone closes that gap. Every downstream consumer needs
text: translation parses cues,
alassneeds a file it can read (#194), andthe sidecar written into the title folder has to be in a known encoding
(#195).
Decode once, in
arr-subs, between download and everything else:chardetngorequivalent — and transcode to UTF-8.
writing mojibake into the library. A subtitle that cannot be decoded is a
failed attempt (#186 already records a failure reason).
Sidecars on disk are UTF-8. That is what §15's "audit by
ls" property isworth nothing without: a file nobody can read is not a satisfied want.
Found while implementing #190.
Depends on: #184
Implemented:
Fetched::decode() -> Result<String>inarr-subs(newdecodemodule). It sniffs a UTF-8/UTF-16 BOM first viaencoding_rs::Encoding::decode, and otherwise detects the encoding withchardetngand transcodes. Returns the newError::Decode { candidate, detail }when the guessed encoding still can't decode the bytes cleanly, rather than writing mojibake. Addedchardetngandencoding_rsas pinned workspace deps.Branch:
subtitles/212-decode-utf8.just cipassed (531/531 tests, clippy and lint checks clean).Findings
Provider::downloadorFetched::decodeoutside tests — no live caller wired up. Expected: #194 (alass) and #195 (sidecar write) are the ones that will consume this.