An EPUB generator packages the source it receives; it is not a repair service for text that was decoded incorrectly beforehand. The safest control is a quarantine gate between manuscript preparation and generation. Every admitted chapter needs a known encoding, a known line ending, a content check, and a stable identity.
The STUDIO-239 measurement supplies a compact baseline for that gate. Five files containing the same Japanese passage were identified independently, and the selected working tab read back UTF-8. It did not demonstrate the generator correcting a damaged file, nor did it operate a deliberately wrong decoding in the graphical interface.
The Generator Is the Last Step, Not the Repair Step
When a manuscript looks suspicious, do not begin by generating an EPUB and hoping the conversion will normalize it. First decide whether the source bytes have been decoded with the intended character set. A package can be structurally valid while its paragraphs contain replacement characters, question marks, or plausible-looking substitutions.
Write the admission rule before the build: only a separately named UTF-8/LF copy that has been reopened and compared with the approved manuscript may enter the selected chapter list. This keeps cover, metadata, navigation, and layout work from obscuring an input problem that should have been resolved earlier.
Build an Admission Sheet for Every Chapter
Give each chapter one row with source path, source digest, detected encoding, line ending, character count, and three textual sentinels. Add a decision column: admitted, quarantined, or awaiting editorial review. The sheet belongs to the source revision, so a changed digest automatically returns the row to review.
Do not reduce the decision to a single character count. Two different texts can have the same count, and UTF-16 byte-order information can affect how inspection reports the file. Use a beginning heading, a rare middle phrase, and the final sentence to make accidental substitutions visible. Chapter order should be recorded in the same build receipt but judged separately from encoding.
The admission sheet also needs an owner and a time. If a translator or editor supplies a later revision, compare the new digest and rerun that row instead of copying the previous result forward. A book assembled from ten individually approved chapters is not approved after one of those files changes. This small rule stops an old test result from being attached to new bytes.
What the Five Specimens Actually Measured
Rune inspected the STUDIO-239 passage as UTF-8/LF/39 characters, Shift_JIS/LF/39, EUC-JP/LF/39, UTF-16LE/LF/40, and UTF-16BE/LF/40. After the UTF-8 specimen was opened, the working tab returned encoding=UTF-8. Those observations establish that the named files were distinguished and that the selected tab held the intended setting.
They do not prove that every file labelled “UTF-8” is healthy, and they do not show a saved wrong-decoding failure. File extensions and Finder names are not evidence of encoding. The EPUB generator encoding decision must remain tied to inspection output and manuscript content, not to a label copied from the file name.
Quarantine a Suspicious Copy Before Packaging
Suppose a chapter opens with one corrupted name while the rest appears normal. Preserve that file and its digest as the failed input. Create a diagnostic copy, test the likely source encoding, and compare the sentinels with an approved reference. If the correct characters cannot be recovered from the available bytes, stop and obtain a verified source rather than inventing a look-alike replacement.
The quarantine folder should never be part of the generator’s selected-file list. This makes failure safe: the bad artifact remains available for analysis, while the build configuration continues to point only at admitted copies. A later operator can reproduce the rejection instead of receiving an unexplained “fixed” file.
Generate a Candidate With a Traceable Identity
Once every chapter is admitted, freeze the ordered list and record its digests. Generate to a new output name, never over the previous accepted EPUB. The export receipt should connect the candidate digest to the exact chapter matrix and to the metadata revision used in that run.
Reopen the EPUB as a package. Confirm that all manifest references resolve, navigation files exist as expected, and the content XHTML contains the sentinels from each source. Structural inspection answers whether the package is coherent; sentinel inspection answers whether the intended text reached it. Neither result should be substituted for the other.
Diagnose a Valid Package With Bad Prose
If the EPUB passes structural checks but a sentinel is wrong, preserve the candidate. Compare the affected XHTML with the admitted source. A correct source paired with incorrect XHTML points toward conversion; an already damaged source points back to admission. In both cases, repair the earliest failed layer and generate a different candidate name.
Do not edit the XHTML inside the EPUB merely to make a final check pass. That change is detached from the manuscript and disappears during regeneration. The failed candidate is useful precisely because its digest and source matrix explain how the defect reached the package.
Release Only the Candidate That Closes the Chain
The release record should list the five baseline measurements, the actual project chapters, each admitted digest, the UTF-8/LF reopen result, the ordered selection, the generated EPUB digest, and the package-plus-sentinel inspection. If a value is missing, leave the gate open rather than filling it with an assumption.
The fixed STUDIO-239 evidence covers CLI inspection and tab setting readback. It does not prove retailer acceptance, identical reader rendering, or automatic repair of corrupt input. A successful generation is defensible when another operator can start from the chapter matrix, reproduce the source decision, and identify exactly which candidate was accepted.


