Prevent Garbled Text Before Saving or EPUB Export

The strongest fix for garbled text is preventing a damaged save from being created. To prevent garbled text in a text editor, identify the source encoding, resolve unrepresentable characters in a working copy, reopen that copy, and only then pass it to EPUB export. Protecting the untouched source matters more than patching a few visible symbols.

A two-stage save and export check

UTF-8, Shift_JIS, and UTF-16LE versions of one Japanese passage were identified correctly, with decoded counts of 288, 288, and 289. The UTF-8 working copy reopened as UTF-8 with LF and retained its content. An EPUB built from it then passed local inspection with six spine entries and both navigation documents.

The dangerous response to a garbled display is manually fixing the visible characters and overwriting the source. Invisible changes and tail loss may remain. Recovery should start from a new duplicate and the correct decoder, followed by checkpoint comparison.

The red highlight and autosave pause are documented UI protections but were not visually measured here. Accept the prevention workflow when the source is unchanged, the duplicate reopens with intentional encoding and newlines, and package validation passes as a separate check. Existing binary corruption and OCR remain outside scope.

Close the text gate first

The evidence matrix stores one passage as UTF-8, Shift_JIS, and UTF-16LE. Rune identified each format and reported decoded character counts of 288, 288, and 289. The UTF-8 specimen was selected for saving. After the workspace was closed, it reopened as UTF-8 with LF, retained the same decoded text, and had digest a65fcb751d8c89f862ad1249c482b57f62b2e8d2ff7ab933ca7f02c63d596902.

Open a separate package gate

Only the accepted text copy entered the synthetic one-chapter export. Reopening the EPUB produced valid=true, six spine entries, zero images, and both navigation formats. These observations answer package-structure questions. They do not retroactively prove that an arbitrary source was decoded correctly, just as a clean editor view does not prove that export created a sound container.

Look for corruption at stable checkpoints

Choose a recognizable opening phrase, a proper name or mixed-script line, and a unique final token. Compare those locations after reopening the saved copy. A replacement glyph such as �, a changed question mark, or a missing tail token should stop the workflow. Do not repair the damaged display by retyping; return to an untouched duplicate and correct the decoding assumption.

Do not depend on an unseen warning

Rune Studio documentation describes red highlighting and a pause in automatic saving when the selected encoding cannot represent text. This command-line run did not render those interface states. The prevention method therefore remains valid even when no warning is visible: preserve the source, inspect formats, save separately, close, and reread before packaging.

Garbled text prevention has two receipts. The text receipt names UTF-8, LF, equality, and the saved digest. The EPUB receipt names the independently inspected archive, six spine items, zero images, navigation presence, and local validity. Keep the original until both receipts pass; retailer ingestion and recovery of already corrupted bytes remain separate work.

After package export, inspect generated XHTML checkpoints as well as the container structure. A valid archive can faithfully package already corrupted input. Searching for the same opening phrase, proper name, and tail token in generated content links the text receipt to the package receipt. If one checkpoint differs, return to the transformation that created XHTML rather than reopening the source with random encodings.

A re-export should use a new filename and a recorded pair of digests: accepted text copy and produced EPUB. This prevents a reviewer from opening yesterday's clean package while today's source has changed. “Latest” is not a reproducible identifier. The evidence pair explains exactly which source produced which archive.

If the saved text is correct but generated XHTML is wrong, preserve both and investigate markup conversion. If the saved text itself is wrong, abandon that copy and restart from the untouched source. The two-gate design locates the earliest failed artifact, making recovery smaller and avoiding repeated edits to a downstream file that will be regenerated.

Finally, do not broaden local validity into a promise about retailer acceptance or every reading system. The current evidence supports a controlled UTF-8/LF source, exact readback, and one locally coherent, text-only EPUB. Store ingestion, font substitution, and repair of bytes that were corrupted before the source was preserved require their own tests and decisions.

Text equality also needs a declared normalization policy. Visually similar composed and decomposed Unicode sequences may behave differently in search or counting. Report byte equality separately from any normalized comparison, and never normalize merely to hide a mismatch. The submitted revision should preserve intentional code points as well as readable appearance.

For scheduled production, run the text gate immediately before export rather than relying on an inspection from an earlier draft. A changed source digest invalidates the old receipt. Recheck encoding, line ending, and checkpoints, then produce a newly paired EPUB digest. This prevents a late copyedit from bypassing the very preflight intended to protect it.

The method remains practical because failures have clear owners. A decoding mismatch returns to source handling; a generated-XHTML mismatch returns to conversion; a structural issue returns to packaging. Keeping those routes separate reduces guesswork and ensures that a local valid=true result never silences an upstream text warning.

Retain the evidence until the recipient confirms ingestion of the intended digest. If a later package differs, inspect that artifact anew instead of borrowing the six-spine result. The scope of every acceptance statement is one named source and one named EPUB.