Save Large Text Safely When Encoding Errors Are Present

If a text editor is handling large data with encoding errors, do not overwrite the received file. Detect the problem in a duplicate, reject any failed destination, and save the repaired version under a new name. Accept it only when the source stayed unchanged, the repaired copy has no remaining candidates for the destination encoding, and fixed checkpoints still match. In the measured 320,000-character sample, one real Shift_JIS conversion error was taken through rejection and repaired-copy readback.

Quarantine the questionable source

Older Japanese documents can look normal at the top while a symbol near the end is decoded incorrectly. Rename the untouched delivery received-original.txt and create encoding-check.txt for investigation. Do not guess an encoding and save immediately; that can turn a reversible display problem into a changed source file.

Inspect characters that commonly expose a mismatch: circled numbers, wave dashes, vendor-dependent symbols, and private-use characters. For each candidate, record the original character, the proposed replacement, and the reason the target encoding needs it.

Use the actual destination encoding. A character that is harmless in UTF-8 may be unrepresentable in Shift_JIS. The dedicated duplicate used here contained one 😀 near the end. It was placed only in disposable test material, never in the preserved source manuscript.

Reproduce a conversion error in a 320,000-character copy

The duplicate contained 320,000 UTF-8 characters across six LF-delimited lines. Inspecting it for Shift_JIS conversion found one unconvertible range: the emoji at offset 319,980. A write using that content and a separate Shift_JIS destination was then rejected as unconvertible. No destination file was created.

The source hash was identical before and after the rejected write. After an explicit character decision, a separately named UTF-8 repair copy reopened at 320,000 characters with zero Shift_JIS conversion candidates. The fixed markers FIXED660-A and FIXED660-B each appeared once. This establishes the complete measured path: detect a real error, produce no failed output, preserve the source, and accept a clean named copy.

Reject the failed destination and inspect a repaired copy

Use this sequence when the source matters:

  1. Preserve the delivered file and inspect only a duplicate.
  2. Record encoding, line endings, character count, and unconvertible candidates.
  3. Attempt the destination encoding and confirm that a rejected write produced no file.
  4. Decide whether to substitute the character or retain UTF-8; do not accept an unexplained replacement.
  5. Save to a new filename such as repaired-utf8-copy.txt.
  6. Reopen it and compare the remaining candidate count, total characters, and fixed checkpoints.

A matching character count cannot prove that every character kept the same meaning, so compare the candidate list as well. Conversely, finding the end marker does not prove the middle of the document is clean.

Separate documented screen behavior from the measured write rejection

Rune Studio’s current Mac documentation describes detection of major Japanese encodings, red marking of unconvertible characters, and a pause in autosave until those characters are resolved. Those are documented behaviors, including visual behavior in the app.

The measured controls in this article are different and narrower: one conversion candidate, a rejected separate-path write, no failed output, an unchanged source hash, and a repaired named copy with zero candidates. The warning dialog, red highlight, disabled-save appearance, autosave pause, and autosave resume were not visually observed. If those cues matter to your workflow, verify them in the current build with a disposable copy. No Mac-to-Mac speed comparison was performed.

Preserve the source, then accept the copy

This workflow is about isolating a real encoding problem, not managing autosave history. Keep the source untouched, require a rejected conversion to leave no destination behind, make the character decision in a duplicate, and accept only a separately named file that reopens with zero remaining candidates and matching checkpoints.

The current Mac app’s encoding safeguards are described on the Rune Studio website.