’ Instead of an Apostrophe: What the UTF-8 Error Means and How to Fix It
Seeing ’ (often read as ⠀ tm) where an apostrophe belongs? Learn why UTF-8 text gets misread, how to repair it safely, and when a plain apostrophe is the better choice.
If a sentence like “don’t” shows up as “don’t”, the text has not been corrupted at random. A curly apostrophe stored as UTF-8 was read back using a different character encoding, most often Windows-1252. The three odd characters, which people often describe as “â € tm” because the trademark sign resembles a small “TM”, are the visible trace of that mismatch. This guide explains what changed, how to judge a repair, and when a plain straight apostrophe is the safer choice.
Short answer: fix the encoding, not just the symptom
The reliable fix is to make every step that handles the text agree on UTF-8: the file, the database connection, the server header and the page or app that displays it. A find-and-replace on “’” is useful for cleaning text that is already damaged, but it does not stop the problem from recurring. The main benefit of keeping curly apostrophes is typographic polish. The decisive tradeoff is that they depend on correct encoding at every step. If your text passes through systems you cannot control, such as old CSV exports, email templates, legacy databases or plain-text feeds, the straight ASCII apostrophe (') is the more robust option because it is stored as the same single byte in UTF-8, Windows-1252 and ASCII and cannot turn into mojibake this way.
What actually changes: bytes read under the wrong encoding
This is not a font, mirroring or display-style effect. The stored characters themselves are being misinterpreted. The typographic apostrophe is the Unicode character U+2019, RIGHT SINGLE QUOTATION MARK. In UTF-8 it is written as three bytes: E2 80 99. Software that assumes Windows-1252 treats each byte as a separate character instead of decoding the three as one.
| Byte | Meaning in Windows-1252 |
| E2 | â (a with circumflex) |
| 80 | € (euro sign) |
| 99 | ™ (trade mark sign) |
So one apostrophe becomes “’”. If that wrong text is then saved again as UTF-8 and misread a second time, which is called double encoding, it grows into a longer string such as “’”. Each extra round trip makes the damage longer and harder to recognize.
Related sequences from the same mistake
Other punctuation that starts with the same UTF-8 bytes breaks in the same way, so these sequences often appear together in one document:
| Intended character | Unicode | Typical mojibake |
| ’ right single quote / apostrophe | U+2019 | ’ |
| ‘ left single quote | U+2018 | ‘ |
| “ left double quote | U+201C | “ |
| ” right double quote | U+201D | †followed by an invisible or missing character |
| – en dash | U+2013 | – |
| — em dash | U+2014 | — |
| … ellipsis | U+2026 | … |
The right double quote is a special case. Its last byte, 9D, has no assigned character in Windows-1252, so the result may look like a bare “— or show a replacement box, depending on the software. A capital “” usually points to a related but different byte pattern. For example, a non-breaking space (UTF-8 bytes C2 A0) misread the same way appears as “” followed by a space. If your text shows “” rather than “â” before the euro sign, check which original character was involved instead of assuming it was an apostrophe.
Where the mismatch usually comes from
- A web page served without a UTF-8 declaration, or with a server header that names a different charset than the file uses.
- A database or connection set to a legacy character set while the application sends UTF-8 (in MySQL, utf8mb4 is the setting that covers full Unicode).
- A CSV or text file saved as UTF-8 and opened in a spreadsheet or editor that assumes a regional legacy encoding.
- Text pasted from a word processor, which often converts straight apostrophes to curly ones automatically, into a system that does not handle UTF-8 correctly.
- Email or export tools that re-encode content without labeling the result.
Preventing it at the source
Declare the encoding at every layer that interprets text. For HTML, that means the HTTP header and the document should both state UTF-8:
Content-Type: text/html; charset=utf-8
<meta charset="utf-8">
For databases, set both the stored column character set and the client connection to UTF-8. For files, save explicitly as UTF-8 and, when importing into spreadsheets, choose the UTF-8 option in the import dialog rather than double-clicking the file. Exact menu names vary by application and version, so check the documentation for the tool you use.
Repairing text that is already damaged
When the damage comes from a single Windows-1252 misreading, it can often be reversed by turning the wrong characters back into bytes and decoding those bytes correctly as UTF-8. In Python:
broken = "don’t"
fixed = broken.encode("cp1252").decode("utf-8")
print(fixed) # don’t
Limits to know before relying on this approach:
- It only works if the text was misread exactly once, as Windows-1252. Double-encoded text needs the step repeated, and each pass should be checked.
- Strict conversion can fail on sequences whose original byte has no Windows-1252 character, such as the broken right double quote. Dedicated repair libraries, for example the open-source Python package ftfy, are designed to handle these edge cases, but review their output rather than assuming every result is correct.
- Running the repair on text that is already correct can damage it. Test on a copy first.
- A plain find-and-replace (for example “’” to ’ or to ') is simple and transparent. Replace the longer double-encoded sequences before the shorter ones so a partial match does not leave fragments behind.
Does the broken text survive copying and sharing?
Yes, and that is the problem. Once the text has been saved in its broken form, “’” is no longer a display glitch. It is three real characters. Copying, pasting, quoting or syndicating that text carries the error along, and changing the font or the viewer will not fix it. Only text that is stored correctly but displayed with the wrong encoding can be fixed by changing how it is viewed.
The damage also reaches beyond appearance:
- Search: a search for “don’t” or “dont” will generally not match “don’t”, so affected pages and records can become harder to find, both in site search and in database queries.
- Assistive technology: screen readers read the characters that are present, so the mojibake may be announced as separate symbols rather than skipped. How it sounds depends on the screen reader and its punctuation settings. No scoped test results were available for this article, so check with the specific tools your audience uses.
- Editing and data quality: spell checkers flag the affected words, word counts and string lengths change, and exact-match comparisons between clean and damaged copies fail.
- Trust: visible encoding errors in published copy make content look neglected, even when the underlying information is accurate.
Curly or straight apostrophe: which should you keep?
Keep curly apostrophes (’) in published prose when you control the whole pipeline and have confirmed it is UTF-8 throughout. They match standard typographic conventions, and in a correctly configured system they are just as searchable and copyable as any other character. Prefer the straight apostrophe (') in code, configuration files, command-line input, identifiers, data meant for exchange, and any workflow where the text passes through tools whose encoding you cannot verify. In those contexts the straight apostrophe is often expected anyway, and it cannot break into “’”. Converting curly apostrophes to straight ones keeps the meaning and readability of ordinary text intact. The only cost is a small loss of typographic polish.
What this guide could not verify
The byte sequences and Unicode code points above follow from the published UTF-8 and Windows-1252 definitions. No tests of specific platforms, content management systems, spreadsheet versions or screen readers were supplied for this guide, so behavior in a particular product should be confirmed in that product before you rely on it.