seconv: reject unknown --encoding values, add --encoding:source#11045
Merged
Conversation
A typo like --encoding:NONSENSE was silently substituted with UTF-8, producing mojibake without any indication. Validate the value the same way --input-encoding-fallback already does and exit 1 on a bad name. Also adds --encoding:source — a sentinel that resolves per-file to the input's detected encoding (BOM/no-BOM preserved for UTF-8), restoring the behavior the old SE CLI offered. Fixes #11037 (points 4 and 5) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--encoding(mirrors the existing--input-encoding-fallbackvalidation) instead of silently substituting UTF-8 and producing mojibake. Error message hints at the newsourcevalue andseconv list-encodings.--encoding:source— a sentinel that resolves per-file to the input file's detected encoding (preserving UTF-8 BOM vs. no-BOM), restoring the behavior the old SE CLI offered.Addresses points 4 and 5 of #11037.
Test plan
seconv file.srt sami --encoding:NONSENSEexits 1 with a clear errorseconv file.srt sami --encoding:utf-8still works (regression)--encoding:sourceon a UTF-8-with-BOM input preserves the BOM on output--encoding:sourceon a UTF-8-no-BOM input preserves no-BOM on output--encoding:source --input-encoding-fallback:windows-1252round-trips Windows-1252 bytes correctly--encoding:SOURCE(case-insensitive) workssource🤖 Generated with Claude Code