THE GITHTML FIELD GUIDE
Repair garbled punctuation and characters in an HTML export
Check the file's actual encoding and the export process before replacing visible characters one by one. Save the document as UTF-8 and declare that encoding early in the head. If the text was already misdecoded during conversion, regenerate from an undamaged source; metadata cannot reconstruct characters that were previously corrupted.
Locate where corruption begins
Compare a distinctive sentence in the original source, generated HTML, and rendered document. Curly quotes, accented names, mathematical symbols, and non-Latin text make useful probes because simple English letters can survive several mismatches unnoticed. Determine whether the HTML bytes already contain the wrong characters or whether the browser is interpreting correct bytes incorrectly.
If the source is clean but the exported file is not, inspect the converter's input and output encoding settings. If both are damaged, recover an earlier correct version before generating again. Repeatedly opening and saving corrupted text can make the error harder to trace. Keep a copy of the original artifact while diagnosing rather than overwriting the only evidence.
Use a clear encoding declaration
A UTF-8 declaration near the beginning of the document removes an avoidable ambiguity, but it must match the actual saved bytes. Merely inserting the tag into a differently encoded file is not a conversion. Use an editor or export tool that lets you choose the encoding and then inspect the resulting artifact.
HTML character references can represent specific characters when needed, but converting every non-ASCII character into a reference is not a substitute for a sound encoding pipeline. Ordinary multilingual prose can be stored directly in UTF-8. Keep code examples especially careful: visually similar punctuation can change the meaning of a command or a configuration value.
Verify with representative text
Create a short test sentence containing the actual languages and symbols used in your document. Include a filename or command if those were affected. Check the exported artifact in the intended reader and in a local browser. A successful check of plain ASCII text says little about whether the original defect has been resolved.
- Find the earliest stage where the text changes incorrectly.
- Regenerate from a clean source where possible.
- Save as UTF-8 and keep the declaration near the start.
- Check names, punctuation, symbols, and code separately.
- Do not replace unknown characters with guesses when their original meaning matters.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Encoding check</title>
</head>
<body><p>Café — résumé — 20 °C</p></body>
</html>Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.