Skip to content
hostcomplex

What Is UTF-8?

Maarten Soetens 3 min read

Characters, Unicode and Encodings

UTF-8 is a character encoding: a method for storing text as bytes so computers can save, send and display it. Computers store numbers, not letters, so every character must be mapped to a number. Unicode assigns a unique number, called a code point, to characters from nearly all writing systems, and an encoding such as UTF-8 defines how those numbers are written as bytes.

UTF-8 uses between one and four bytes per character. Basic Latin letters use one byte and match the older ASCII standard, while accented letters, Cyrillic, Arabic, Chinese and emoji use more. It is the dominant encoding on the web and the recommended default for new websites, including those built with PHP.

Why Text Turns Into Garbled Characters

Garbled text, sometimes called mojibake, appears when bytes written in one encoding are read as another. For example, the word café saved as UTF-8 may display as café if the page is decoded as a single-byte Western encoding. The text is not lost; it is simply decoded with the wrong rules.

To avoid this, the encoding must match at every stage where text is stored or transferred:

  • Source files: the editor saves files as UTF-8.
  • HTTP headers: the server declares the character set, for example Content-Type: text/html; charset=UTF-8.
  • HTML: the page declares its encoding in a meta tag that names UTF-8. For the basics of how HTML is structured, see HTML vs CSS vs JavaScript.
  • Databases and connections: data is stored and read using a character set that supports UTF-8.

A Multilingual Shop With Question Marks

A shop sells products with names in Polish, German and Japanese. The product pages look fine during development, but on the live site some names show question marks. The product data was stored in a table using a single-byte character set, while the page declared UTF-8. Characters outside that older set could not be stored correctly, so the damage happened before the page was built.

The fix is to make every layer agree on UTF-8 and to check whether existing data was already corrupted. Encoding problems are best prevented at the start of a project rather than patched later.

Frequently asked questions

Why Do I See Question Marks or Strange Symbols on My Website?

Usually because one part of the chain uses a different encoding from another. Check which encoding the page declares, what the database connection uses and how the source files were saved. Question marks often mean characters could not be converted, while accented letters that split into two odd characters usually mean UTF-8 bytes were decoded as a single-byte encoding.

Should I Use UTF-8 for Every Website?

For new projects, yes; it is the sensible default. It supports every language, is supported by all major browsers and programming languages, and is compatible with ASCII for basic text. Older sites may use other encodings for historical reasons, and converting them to UTF-8 is usually worthwhile when the site is redeveloped.

Does UTF-8 Make Files Larger?

It can, for some text. Characters outside basic Latin take two to four bytes, so text in Chinese or Arabic may need more space than in a single-byte encoding. For mostly English text the difference is negligible, and the compatibility benefits outweigh the cost.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.