Privacy

Fix broken accents and strange characters on a website without corrupting more text

Trace one damaged phrase from its original file to stored content, response bytes and browser display. Correct the faulty boundary instead of relabeling or replacing everything.

Made by Pagember · Editorial policy

Editorial guidancePublished Updated Sources

The short answer

Find the first stage where a known phrase becomes damaged before changing any encoding setting. Keep the original file and a recoverable copy, then compare the source, stored content, delivered bytes and browser display. The pattern helps, since café instead of café usually means UTF-8 read as a single-byte encoding. Repair only that import, storage or delivery step, then check a representative set of characters.

On this page10 sections

Find where a known phrase first becomes damaged before changing encoding settings. The original document, stored content, delivered bytes and browser display are separate stages. Labeling all of them UTF-8 does not repair a phrase that was already decoded and saved incorrectly.

Conceptual UTF-8 bytes C3 A9 decoded as é or the mojibake text é, showing why the stored bytes and selected decoder must both be inspected.

This guide focuses on HTML pages. It uses a hypothetical café workshop handout as the running example. Keep the original file and a recoverable copy of affected content before experimenting.

Recognize the kind of failure

A correct word such as café might appear as café after bytes are interpreted using the wrong encoding. This kind of garbled text is often called mojibake. A replacement character, identified as U+FFFD, can instead indicate that a decoder could not represent an input sequence. A box where a symbol should be can also be a font-coverage problem.

The pattern of the damage usually tells you which mistake happened:

What you seeWhat it should beLikely cause
é è ã öé è ã öUTF-8 text read as Windows-1252 or ISO-8859-1
’ “ †—’ “ ” —UTF-8 curly quotes and dashes read as Windows-1252, common after pasting from a word processor
£ or a stray  before a space£ or a non-breaking spaceUTF-8 symbol or non-breaking space read as a single-byte encoding
é or longer chains of à and ÂéText that was mis-decoded, saved, then mis-decoded again (double encoding)
� or ? in place of lettersAny accented characterSingle-byte text served as UTF-8, or characters lost during a conversion

These symptoms suggest questions, not a complete diagnosis. If the stored text already contains the unwanted characters, changing the page's declaration may faithfully display that damaged text. If the stored text is correct but the response is decoded incorrectly, rewriting the database is the wrong layer.

ObservationQuestion to investigateFirst comparison
Only an imported paragraph is garbledDid the import decode the source correctly?Original file and stored paragraph.
Accents across the delivered page are wrongDo response bytes and encoding declarations agree?Actual response, headers and browser interpretation.
A character is correct when copied but displays as a boxDoes the active font cover it?Text value and rendered font.
The same text is damaged in the editor and public pageWas the corruption saved earlier?Last good source and current stored content.

Keep bytes, labels and characters separate

A character is not the same thing as the bytes used to encode it. In UTF-8, the character é is represented by the hexadecimal bytes C3 A9. Interpreting those bytes through an incompatible encoding can produce different characters; saving that result can turn a delivery mistake into stored corruption.

W3C's encoding guidance recommends UTF-8 for new web content. The content must actually be saved in that encoding. A label describes how data should be interpreted; it does not transform the file's existing bytes.

For the workshop handout, preserve the source file unchanged and make a separate working copy. Record the application's reported file encoding and the known correct sentence. Do not repeatedly save the only original with different encoding options while guessing which one makes the preview look better.

Follow one phrase through the publishing path

Choose a short phrase whose correct spelling is known. In the hypothetical example, it includes an accented letter, a curly quotation mark and an em dash. Compare the original document, the import or editor view, a controlled content export and the public response.

Record the first disagreement. If the original is correct but the imported draft is wrong, examine the import's supported input encoding. If the draft is correct but the public page is wrong, inspect rendering and delivery. If only a search excerpt or email is wrong, follow that separate output path instead of assuming the article body shares it.

Keep comparisons private when they contain unpublished or personal information. A diagnostic note needs the boundary and a minimal synthetic example, not a full database dump pasted into a public forum.

Inspect the response that the browser actually received

The Content-Type header reference explains the media type and optional charset parameter. For an HTML page, an illustrative response declaration is:

Content-Type: text/html; charset=utf-8

Check the final document response in the browser's network tools, including whether it came through a cache. Do not inspect an image or a redirect response and assume its headers describe the HTML article. The compressed delivery indicated by Content-Encoding is a separate matter from character encoding.

Compare the public response with the controlled source under the site's documented tooling. Merely opening a downloaded file in an editor that guesses encodings is not a reliable byte comparison. Ask the maintainer to identify the actual encoding at the boundary when the available interface cannot show it confidently.

Make declarations agree with the data

W3C's HTML declaration guide places the complete meta declaration within the first 1024 bytes, normally near the start of the head. A simple illustrative declaration is:

<meta charset="utf-8">

Use the supported template or application setting to produce the declaration. Check the actual response rather than adding conflicting tags in several plugins. A correct declaration paired with legacy-encoded bytes is still a mismatch.

The HTML encoding-detection algorithm includes byte-order marks, transport information and in-document declarations. In ordinary HTML detection, a recognized initial BOM takes precedence over the HTTP charset, which takes precedence over a meta declaration. The complete algorithm has further context, including user-override considerations. Do not apply that short hierarchy blindly to XML or unrelated formats.

Adding a BOM to conceal a conflicting server configuration is a poor substitute for a consistent publishing path. Establish which component supplies each declaration and correct the mismatch through its supported configuration.

Choose the smallest recoverable correction

If one imported draft is damaged, return to the preserved original and repeat that import with the documented correct encoding in a rehearsal environment. Compare the result before replacing the affected live content. Do not convert an entire database to fix one paragraph.

If correct stored text is delivered with a wrong charset, correct that response path and inspect fresh and cached responses. If an intermediate export or integration changed the text, repair that transformation rather than overwriting every downstream copy manually.

For a database-wide issue, involve the maintainer with a backup and tested migration plan covering the application's connection, storage and output behavior. A database character-set setting is not a universal repair switch. Our WordPress migration workflow provides broader recovery planning, not an encoding-conversion command.

WordPress and MySQL: where encoding goes wrong

On a WordPress site, most mojibake appears after a migration, a database import or a pasted document, and the database connection settings decide how text is read and written. Check these before changing anything:

  • wp-config.php: look for define( 'DB_CHARSET', 'utf8mb4' );. Current installs use utf8mb4, older ones utf8. After a move, keep the same value the site used before; changing it on an existing database alters how stored text is read and can create the garbling you are trying to fix.
  • Table character set: in phpMyAdmin or your host’s database tool, the Collation column for the WordPress tables should show a utf8mb4_… or utf8_… collation. A latin1 table holding UTF-8 bytes is a common source of double encoding after export and import.
  • Export and import: keep the character set consistent at both ends. With the command line, mysqldump --default-character-set=utf8mb4 exports the bytes as stored; in phpMyAdmin, choose utf-8 as the file character set on both export and import. Open the dump in a text editor and look for a known accented word before importing it.
  • Search and replace: replacing é with é across the database can repair one known pattern, but run it on a copy with a dry run first and use a tool that handles serialized data. The serialized data guide explains why a plain SQL replace can break settings.

Take a restorable backup before any of these steps, from your host or a service such as BlogVault. If the damage arrived with a content transfer rather than a full move, the export and import guide shows how to redo that transfer from the original source.

Know when the original is necessary

Some garbling can be reversed only when its transformation is known and the original information survives. If different characters were replaced by the same placeholder or bytes were discarded, the damaged string may no longer contain enough information to reconstruct the original.

Use the last good document, backup or source-system record to resolve that loss. A global replacement of every à or question mark can alter legitimate text and still leave other corruption. Correct the affected records with verified originals and keep the scope reviewable.

Language selection is a separate concern. Changing a site's locale does not repair incorrectly decoded text. Our translation workflow explains content and interface language layers without treating them as encoding repairs.

Verify more than the first accent

Use a controlled sample containing the languages and symbols the site actually supports: accented letters, punctuation, currency signs and relevant non-Latin text or emoji. Check the editor, saved content, public page and any affected secondary output. A corrected café heading is insufficient if the next save damages the paragraph again.

Keep the original backup until the repair and subsequent publishing cycle have been verified. Record the faulty boundary, scoped change, tested sample and remaining questions. The dependable result is a consistent path from correct source characters to correct public text, with no unexplained mass substitutions along the way.