Weird Characters on Your Website Instead of Special Letters? How to Fix UTF-8

Short answer
Why does my website show weird characters?
Weird characters on a website mean text was saved in one encoding and read in another. When é turns into é or an apostrophe becomes ’, the cause sits in one of five places: the meta charset tag, the server's HTTP header, the file encoding, the database character set or the database connection.
The technical name for this mess is mojibake: the bytes are right, the interpretation is wrong. Fortunately, once you find the cause, the fix is usually one setting. The bad news is that a "fix" in the wrong place can damage data permanently. In this guide, Talha Aslan and team share the diagnosis order we use on real projects. First, you read the symptom and find the layer. Then you touch only that layer.
What do weird characters tell you about the cause?
The shape of the damage is not random. Each pattern points strongly to the layer that misread the text. The table below lists the symptoms we see most often and where to look first.
| What you see | Likely cause | Where to look first |
|---|---|---|
| é instead of é, ’ instead of an apostrophe, ü instead of ü | Some layer reads UTF-8 text as a single byte encoding | HTTP header and meta charset; double encoding in the database |
| A black diamond with a question mark (�) | Windows-1252 or ISO-8859-1 text served as UTF-8 | File encoding, legacy database data |
| Plain question marks (?) instead of letters | Characters got lost passing through a column or connection that cannot hold them | Column character set and connection character set |
| Letters fine, emoji fail to save | The column uses utf8mb3, and emoji need four bytes | Table and column character set |
| Only one page or section breaks | That template file uses a different encoding | The specific file |
| Site fine, exported CSV broken in Excel | The problem is in how the CSV opens, not on the site | CSV encoding |
The last row is a separate topic, so we skip it here; our guide on CSV special characters broken in Excel covers that side. The first row is the most common case, and it usually involves the server or the database connection. Setting up every layer on UTF-8 from day one is a decision made during web design services; we return to that briefly at the end.
What is character encoding, and why is UTF-8 the only sensible choice?
First, computers store text as bytes, not letters. A character encoding is the table that maps byte sequences to characters. If you read the same bytes with a different table, you get different characters. For example, UTF-8 stores é as two bytes. A program that reads those bytes with a single byte Western European table shows two separate characters: "é".
In the past, sites often used single byte tables such as Windows-1252 or ISO-8859-1. Those tables cover Western European letters, but they do not cover most other scripts or emoji. UTF-8, by contrast, covers every language in one encoding. That is why it is the undisputed standard for the web today.
MDN's meta element reference states it plainly: UTF-8 is the only valid encoding for HTML5 documents. Therefore, a new site has no reason to choose anything else. If an older site still runs on Windows-1252, the goal is to move every layer to UTF-8.
Is your meta charset tag in the right place?
Inside the document, the meta charset tag near the top of the page tells the browser the encoding. According to MDN, its value must be utf-8, and the whole tag must sit within the first 1024 bytes of the document. The W3C also recommends placing it right after the opening head tag.
Also, even if the tag exists, its position can be wrong. For example, if a theme prints a long comment block, a large inline style or several tracking snippets before it, the tag may slip past the first 1024 bytes. In that case, the browser tries to guess the encoding, and the guess can be wrong.
- Right click the page and view the source.
- Look for the meta charset tag right below the head tag.
- Check that the value is utf-8 and that no long content sits above it.
- Look for a second, conflicting charset declaration elsewhere on the page.
Fixing the tag only changes how the browser interprets the page. It does not repair data that the database already stores in broken form. We explain that difference further below.
Does the HTTP header override the meta tag?
Yes, it does. The W3C page on declaring character encodings in HTML gives the order of precedence: a byte order mark (BOM) at the start of the file beats everything; next comes the Content-Type header from the server; the in document meta declaration comes last. So if the server announces a different encoding, the browser follows the server even when your meta tag is correct.
To check, open your browser's developer tools, reload the page in the network tab and look at the Content-Type line in the response headers of the first HTML request. If the charset there is anything other than utf-8, the problem lies in the server configuration. On some hosting setups, the default charset changes in the control panel or in a server configuration file; confirm the exact setting name in your host's documentation.
The W3C also advises against relying on the HTTP header alone. After all, headers disappear when someone saves a file locally or runs it through another tool, and server defaults can change over time. So the right setup uses both, and keeps them consistent: utf-8 in the header and utf-8 in the meta tag.
Can file encoding cause weird characters?
Yes, especially with static HTML or hand edited template files. If you save a file as Windows-1252 in a text editor, upload it, and the page declares UTF-8, accented letters turn into black diamonds with question marks. The reason is simple: a single byte é does not form a valid UTF-8 sequence.
In practice, the symptom is usually selective. Most of the site looks fine, while one page, one menu label or one footer line breaks. That points to a single file. The fix is to open the file in your editor and save it again as UTF-8. However, if the file already looks broken in the editor, reopen it with the correct source encoding first; otherwise you save the broken version as UTF-8.
- Check the file encoding in your editor's status bar.
- Make saving every file as UTF-8 a team rule.
- Prefer files without a BOM, especially PHP files, since the invisible bytes can end up at the start of the page output.
- If you use version control, add an encoding rule to the repository.
What if the database stores weird characters?
In content management systems, most text comes from the database. As a result, even with a correct page and file, a database in the wrong character set keeps the problem alive. In MySQL and MariaDB, the character set exists separately at server, database, table and column level, and the column level has the final word.
MySQL's utf8mb4 documentation spells out a key detail: utf8mb4 uses up to four bytes per character and supports all Unicode characters. utf8mb3 uses at most three bytes and cannot store supplementary characters such as emoji at all. According to the documentation, the name utf8 is a deprecated alias for utf8mb3.
Accented Latin letters fit into three bytes, so they survive in a utf8mb3 column. However, when a customer review arrives with an emoji, the insert fails or loses the end of the text. That is why we recommend utf8mb4 for tables and columns on new setups. The collation, which controls sorting and comparison, is a separate decision; a general Unicode collation works well for most multilingual sites. We show the steps for creating a new database in our guide on how to create a MySQL database in cPanel.
Why does the database connection character set matter so much?
Even with utf8mb4 tables, problems return if the application announces a different encoding when it talks to the database. The connection character set acts as the translator between the two. If the application says "I am sending Latin1" but actually sends UTF-8, the database treats each byte as a separate character and "converts" it to UTF-8. The result is double encoded data.
On the PHP side, php.net's mysqli set_charset documentation states that this function is the preferred way to change the connection charset. The same page does not recommend setting it with a query such as SET NAMES. If you use PDO, you declare the charset in the connection definition instead.
In WordPress, the setting lives in the DB_CHARSET constant in wp-config.php. Do not change it before you know the real state of the database. For example, if a database has collected double encoded text over a Latin1 connection for years, switching the constant to utf8mb4 suddenly breaks text that used to look fine. After all, the application now reads the data exactly as stored. If you see a connection error instead, the cause is not the charset; see our article on the error establishing a database connection.
What is double encoding, and why can't display settings fix it?
Double encoding means UTF-8 text goes through a second UTF-8 conversion. In the first step, the application writes é correctly as two bytes. In the second step, some layer treats those two bytes as single byte characters and encodes each of them again. The database now holds the UTF-8 form of "é", not é.
At this point, the problem lives in the data itself, not in the display. No matter how often you fix the meta tag, the HTTP header or the template, you keep seeing "é". The database really hands you those characters.
Still, there is a practical way to recognize it. Look at the table directly in your database tool. If it also shows "é", the data is broken. If é looks correct there but broken on the site, the issue sits in the connection or page layer. That distinction decides which of the fixes below you apply.
One more hint: a double encoded sequence is longer than the original letter. So a column with a length limit, such as a short title field, may cut off the end of the text after double encoding. Truncated titles can therefore be a sign of the same problem.
Why do characters break during a site migration?
In practice, migrations are the most common trigger for encoding problems. You export data, write it to a file and import it on another server. Each of those three steps carries an encoding assumption, and if the old and new servers have different defaults, one assumption turns out wrong.
- During export: if the backup tool runs with the wrong connection charset, the text in the dump is broken from the start.
- In the file: if someone opens the dump in an editor and saves it in another encoding, the content changes.
- During import: if the new server reads the file with a different character set, it encodes correct data a second time.
- In configuration: the new server's default HTTP charset or PHP version may differ.
So before you migrate, note which character set the backup used, and state the same value explicitly when you import. We explain the logic of backup commands in our database backup and restore guide and the full move in our checklist for changing web hosting without downtime. If you need to switch PHP versions on the new server, our article on changing the PHP version in cPanel helps.
How do you fix weird characters step by step?
Above all, the sequence below finds the cause with the least risk. The first steps only read; they change nothing. You move on to steps that change things only after the diagnosis is clear.
- Take a backup. Back up the full database and files, because encoding fixes are hard to undo.
- Classify the symptom. Which pattern from the table do you see: é, a black diamond or a plain question mark?
- Read the HTTP header. Does the Content-Type line say charset utf-8?
- Check the meta charset tag. Is it utf-8 and within the first 1024 bytes?
- Look at the raw data. Does the text look correct in your database tool?
- Check column and table character sets. Are they utf8mb4, or Latin1 or utf8mb3?
- Check the connection character set. Which encoding does the application announce to the database?
- Test the fix in a staging copy. Run the same operation on a copy before touching live data.
We explain how to set up a test environment in our guide on what a staging site is. Encoding fixes rank among the tasks you should always try on a copy first.
Example scenario: product names show é after a migration
As an example scenario, consider a small online store. The owner moves the site to a new host. The next morning, product names read "Café table" and "Naïve print". Yet the fixed text in the page template, such as the "Add to cart" button, still looks correct.
That difference is therefore a strong clue. The template file is fine, so the HTTP header and meta tag are probably fine too. Only text from the database breaks. The team checks the product table in the database tool and sees correct names there. So the data is intact, and the problem sits in the connection.
It turns out the application configuration on the new server does not define a connection charset, and the server default differs. The team sets utf8mb4 for the connection explicitly, and the product names recover. Since nobody touched the data, the fix carries no risk. In the reverse case, with "Café" stored in the table itself, the fix would need a data conversion.
How do you repair data the database already stores in broken form?
If the data really is broken, with "é" stored in the database, you have two options. The first reverses the double encoding: convert the text back to the single byte encoding that misread it, then reinterpret the bytes as UTF-8. The idea is simple, but the practice is risky. If a table mixes broken and correct rows, the conversion damages the correct ones.
The second option replaces known broken sequences with the right characters: é with é, ü with ü, ñ with ñ, ’ with an apostrophe. This method gives you more control. However, systems that store serialized data, such as some WordPress options, save the text length alongside the value, so a plain search and replace can break the structure.
- Try either option on a copy of the database first.
- Start with a small table and check the result on screen.
- Change serialized data only with a tool that understands that format.
- After the repair, fix the connection charset too; otherwise new records arrive broken again.
Why do form submissions or emails contain weird characters?
Browsers usually send form data in the page's encoding. If the page declares the wrong encoding, the é that a visitor types reaches the server in the wrong form. Therefore, broken form data often reflects a page level problem.
Email notifications, on the other hand, form a separate chain. Even if form data lands correctly in the database, the code that sends the email may not declare a charset in the headers and body, and the recipient's mail program then guesses. Subject lines with accented letters also need a special header encoding. Most email libraries handle this on their own, while hand written sending code often skips the step.
To diagnose, compare the same record in three places: the database, the admin panel and the received email. The step where the damage first appears tells you that the cause sits just before it. For instance, if the database and admin panel look right but the email subject breaks, only the sending code needs attention.
Why do smart quotes and dashes from Word turn into weird characters?
For example, text pasted from word processors often carries curly quotes, long dashes and non breaking spaces. These characters sit outside basic ASCII, so they reveal encoding problems first. An apostrophe that turns into ’ is the classic sign that UTF-8 text met a Windows-1252 reader.
The fix is the same as for accented letters: make every layer UTF-8. Still, you can reduce risk at the editorial level too. For example, paste text as plain text in your CMS editor when the formatting does not matter. That way, hidden formatting and unusual characters stay out of the database.
Non breaking spaces also deserve a special mention. They look like normal spaces but behave differently, so they can break search and replace operations and line wrapping. If a phrase refuses to match in a search, an invisible character is a likely suspect.
Which tools help you check character encoding?
You do not need special software for the diagnosis; the tools you already have usually suffice. What matters is knowing which layer each tool shows. Otherwise you may see one correct layer and wrongly rule out the problem there.
- Browser developer tools: the network tab shows the HTTP header, and the source view shows the meta tag.
- Code editor: the status bar shows the file encoding and any BOM; most editors also offer to reopen a file in another encoding.
- Database administration tool: shows table and column character sets, plus the raw data.
- Hosting control panel: holds the PHP version and some server defaults.
- Side by side comparison: the same record in the database, the admin panel and on the site reveals where the damage starts.
As you go through these tools, keep a short note. Writing "correct" or "wrong" for each layer eventually leaves only one wrong layer. Then you apply the fix there and leave the working layers alone.
Do weird characters hurt SEO?
Yes, because search engines read your page much like a browser does. If your title says "Café tables", the search result will most likely show that text too. Users skip it, and the page also struggles to match the search terms people type.
The damage can also spread to meta descriptions, structured data and product feeds. For instance, if product names break in a feed that goes to shopping platforms, ads and listings inherit the same problem. So treat encoding issues as a visibility problem, not merely a cosmetic flaw.
If you hit encoding problems during a migration, you can request a recrawl of key pages in Search Console after the fix. We cover the SEO side of a move in our website migration SEO checklist. Domain names with special letters are a separate subject; our article on IDN domains and Punycode explains the pros and cons.
What are the most common mistakes when fixing weird characters?
In short, most mistakes here fix the display and damage the data. Use the list below as a warning list.
- Changing only the meta tag: if the HTTP header differs, the browser ignores the tag.
- Running a bulk conversion without a backup: reversing double encoding can break correct rows.
- Changing the connection setting at random: on years of double encoded data, it breaks text that used to look fine.
- Saving a broken file as UTF-8: if you do not reopen it with the right source encoding first, the damage becomes permanent.
- Assuming utf8 means utf8mb4: in MySQL, utf8 is an alias for utf8mb3, which cannot store emoji.
- Opening a backup in an editor and saving it: the editor may silently change the file encoding.
Which checklist prevents weird characters for good?
Once every layer runs on UTF-8 and agrees with the others, the problem does not come back. When you build a new site or take over an existing one, confirm each point below.
- Server HTTP header declares charset utf-8.
- Meta charset tag says utf-8 and sits at the start of head.
- All template and code files use UTF-8 without a BOM.
- Database, tables and columns use utf8mb4.
- The application's connection charset is utf8mb4.
- Backup and import commands state the character set explicitly.
- The html element declares the right language.
- Email sending code declares a charset.
Next, add this list to your site documentation. When another team takes over the site or you move to a new server, you can repeat the checks in minutes. That way, the odds of waking up to strange letters in product names after a migration drop sharply.
When does it make sense to get professional help?
The diagnosis steps reveal the cause in most cases. However, when a database mixes double encoded and correct rows, serialized settings come into play and a migration stalled halfway, the repair needs careful planning. One wrong bulk operation can damage years of content at once.
At Talha Aslan and team, our web design services build sites on a clean foundation from the start: lean custom code, a clean server configuration and a multilingual architecture with correct hreflang. You edit content yourself in the admin panel and review every page in a test environment before launch. The code we hand over comes documented, so another developer can take it over.
If your site has aged, breaks on mobile or resists updates, we can also restructure it without losing content or rankings. If you are planning a new project and want to avoid these problems from day one, our corporate website design page explains the scope and lets you send a request through its quote section.



